Author: hselasky
Date: Fri Oct  5 07:50:44 2018
New Revision: 339190
URL: https://svnweb.freebsd.org/changeset/base/339190

Log:
  MFC r338993:
  When multiple threads are involved receiving completion events in LibUSB
  make sure there is always a master polling thread, by setting the 
"ctx_handler"
  field in the context. Else the reception of completion events can stop.
  This happens if event threads are created and destroyed during runtime.
  
  Found by:             Ludovic Rousseau <ludovic.rousseau+free...@gmail.com>
  PR:                   231742
  Sponsored by:         Mellanox Technologies

Modified:
  stable/10/lib/libusb/libusb10_io.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libusb/libusb10_io.c
==============================================================================
--- stable/10/lib/libusb/libusb10_io.c  Fri Oct  5 07:49:01 2018        
(r339189)
+++ stable/10/lib/libusb/libusb10_io.c  Fri Oct  5 07:50:44 2018        
(r339190)
@@ -310,6 +310,9 @@ libusb_wait_for_event(libusb_context *ctx, struct time
        if (tv == NULL) {
                pthread_cond_wait(&ctx->ctx_cond,
                    &ctx->ctx_lock);
+               /* try to grab polling of actual events, if any */
+               if (ctx->ctx_handler == NO_THREAD)
+                       ctx->ctx_handler = pthread_self();
                return (0);
        }
        err = clock_gettime(CLOCK_MONOTONIC, &ts);
@@ -328,6 +331,9 @@ libusb_wait_for_event(libusb_context *ctx, struct time
        }
        err = pthread_cond_timedwait(&ctx->ctx_cond,
            &ctx->ctx_lock, &ts);
+       /* try to grab polling of actual events, if any */
+       if (ctx->ctx_handler == NO_THREAD)
+               ctx->ctx_handler = pthread_self();
 
        if (err == ETIMEDOUT)
                return (1);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to