Thanks, now I can use libusb_handle_events(). What kind of situation the code will run into int usbredirparser_do_write(struct usbredirparser *parser_pub) { ... if ((parser->flags & usbredirparser_fl_write_cb_owns_buffer) && w != wbuf->len) abort(); ... }