FreeBSD Bugzilla – Attachment 225579 Details for
Bug 256296
"No Device" error after using asynchronous API of libusb once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Better bug reproducer
libusbhasbug.c (text/plain), 1.37 KB, created by
Sergii
on 2021-06-05 22:30:37 UTC
(
hide
)
Description:
Better bug reproducer
Filename:
MIME Type:
Creator:
Sergii
Created:
2021-06-05 22:30:37 UTC
Size:
1.37 KB
patch
obsolete
>#include <stdio.h> >#include <libusb.h> >#include <pthread.h> >#include <unistd.h> > >static void * >thread_start(void *arg) >{ > struct timeval tv = { .tv_usec = 0, .tv_sec = 2 }; > while (1) > libusb_handle_events_timeout_completed (arg, &tv, NULL); > return NULL; >} > >int main () { > libusb_context *ctx; > libusb_init (&ctx); > > pthread_t thread_id; > pthread_create (&thread_id, NULL, &thread_start, ctx); > > libusb_device **devs; > ssize_t dev_num = libusb_get_device_list (ctx, &devs); > > printf ("dev count = %zd\n", dev_num); > if (dev_num == 0) return 1; > > // --- open first time to break the device object > > libusb_device_handle *devh; > int code = libusb_open (devs[0], &devh); > printf ("open() = %d\n", code); > if (code != 0) return 1; > > // let the other thread stop in poll() > sleep(1); > > // close the device (replace its methods with stubs) > libusb_close (devh); > > // let the other thread mark device as gone > sleep(2); > > // --- open second time to show that device can't be used > > code = libusb_open (devs[0], &devh); > printf ("open() = %d\n", code); > if (code != 0) return 1; > > // doesn't matter what we try to transfer, device is unusable > int transferred = 0; > unsigned char buf[1] = {}; > printf ("interrupt_transfer() = %d\n", > libusb_interrupt_transfer (devh, 0x00, buf, sizeof(buf), &transferred, 5000)); > printf ("transferred = %d\n", transferred); > > libusb_close (devh); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 256296
:
225431
| 225579 |
225640