From owner-p4-projects@FreeBSD.ORG Sat May 30 13:04:55 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 44BE01065672; Sat, 30 May 2009 13:04:55 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03B081065678 for ; Sat, 30 May 2009 13:04:55 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id CC4A58FC12 for ; Sat, 30 May 2009 13:04:54 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4UD4s5P041292 for ; Sat, 30 May 2009 13:04:54 GMT (envelope-from syl@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4UD4sQG041290 for perforce@freebsd.org; Sat, 30 May 2009 13:04:54 GMT (envelope-from syl@FreeBSD.org) Date: Sat, 30 May 2009 13:04:54 GMT Message-Id: <200905301304.n4UD4sQG041290@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to syl@FreeBSD.org using -f From: Sylvestre Gallon To: Perforce Change Reviews Cc: Subject: PERFORCE change 163081 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2009 13:04:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=163081 Change 163081 by syl@syl_rincewind on 2009/05/30 13:04:04 Add libusb20_lock for libusb20 atomic functions. Release the default_context_lock on libusb_init. Affected files ... .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#21 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.h#4 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#5 edit Differences ... ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#21 (text+ko) ==== @@ -46,6 +46,7 @@ static pthread_mutex_t default_context_lock = PTHREAD_MUTEX_INITIALIZER; struct libusb_context *usbi_default_context = NULL; +pthread_mutex_t libusb20_lock = PTHREAD_MUTEX_INITIALIZER; /* Library initialisation / deinitialisation */ @@ -114,6 +115,7 @@ if (!usbi_default_context) { usbi_default_context = ctx; } + pthread_mutex_unlock(&default_context_lock); if (context) *context = ctx; @@ -773,7 +775,10 @@ libusb20_tr_set_priv_sc0(usb20_xfer, xfer->callback); libusb20_tr_set_priv_sc1(usb20_xfer, xfer->user_data); libusb20_tr_set_callback(usb20_xfer, libusb10_proxy); + + pthread_mutex_lock(&libusb20_lock); libusb20_tr_submit(usb20_xfer); + pthread_mutex_unlock(&libusb20_lock); switch (libusb20_tr_get_status(usb20_xfer)) { case LIBUSB20_TRANSFER_COMPLETED: ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.h#4 (text+ko) ==== @@ -73,6 +73,7 @@ static int handle_timeouts(struct libusb_context *ctx); static int handle_events(struct libusb_context *ctx, struct timeval *tv); extern struct libusb_context *usbi_default_context; +extern pthread_mutex_t libusb20_lock; /* if ctx is NULL use default context*/ ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#5 (text+ko) ==== @@ -187,7 +187,11 @@ usb_handle_disconnect(devh); continue ; } + + pthread_mutex_lock(&libusb20_lock); ret = libusb20_dev_process(devh->os_priv); + pthread_mutex_unlock(&libusb20_lock); + if (ret == 0 || LIBUSB20_ERROR_NO_DEVICE) continue; else if (ret < 0)