root/trunk/libusb-runloop.patch

Revision 98, 1.4 kB (checked in by jps, 16 months ago)

To fix a crash in libusb (usb_bulk_transfer on Mac OS X (CFRunLoopRunInMode)).
More info: https://sourceforge.net/tracker/index.php?func=detail&aid=1770846&group_id=1674&atid=101674
The patch is coming from http://www.ellert.se/twain-sane/
Thanks Ludovic for debuging this.

  • libusb/darwin.c

    old new  
    189189    return "invalid argument"; 
    190190  case kIOReturnAborted: 
    191191    return "transaction aborted"; 
     192  case kIOReturnNotResponding: 
     193    return "the device is not responding"; 
    192194  default: 
    193195    return "unknown error"; 
    194196  } 
     
    207209  case kIOUSBNoAsyncPortErr: 
    208210    return ENXIO; 
    209211  case kIOReturnExclusiveAccess: 
     212  case kIOReturnNotResponding: 
    210213    return EBUSY; 
    211214  case kIOUSBPipeStalled: 
    212215    return LUSBDARWINSTALL; 
     
    838841 
    839842  if (result == kIOReturnSuccess) { 
    840843    /* wait for write to complete */ 
    841     if (CFRunLoopRunInMode(kCFRunLoopDefaultMode, (timeout+999)/1000, true) == kCFRunLoopRunTimedOut) { 
    842       (*(device->interface))->AbortPipe(device->interface, pipeRef); 
    843       CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true); /* Pick up aborted callback */ 
    844       if (usb_debug) 
    845         fprintf(stderr, "usb_bulk_read: input timed out\n"); 
    846     } 
     844    CFRunLoopRun(); 
    847845  } 
    848846 
    849847  CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode); 
    850848   
    851849  /* Check the return code of both the write and completion functions. */ 
    852   if (result != kIOReturnSuccess || (rw_arg.result != kIOReturnSuccess &&  
    853       rw_arg.result != kIOReturnAborted) ) { 
     850  if (result != kIOReturnSuccess || rw_arg.result != kIOReturnSuccess) { 
    854851    int error_code; 
    855852    char *error_str; 
    856853 
Note: See TracBrowser for help on using the browser.