Set debug output to be line buffered

The stub libusb library used for testing writes the control request to a
dump file. By default, this file is block-buffered, and on a typical
Linux system, it waits until it receives about a page worth of data
before flushing it to disk. This results in a delay in monitoring
packets when running a debug program.

This change makes the file line-buffered instead, which results in the
debug output for every single packet getting flushed to disk without
having to wait for a full page of data.
debian-packaging
nirenjan 2020-04-12 16:29:22 -07:00
parent 40b2e9bdac
commit a7caba19df
1 changed files with 2 additions and 0 deletions

View File

@ -240,6 +240,8 @@ int libusb_open(libusb_device *dev, libusb_device_handle **handle)
free(tmp_hdl);
return LIBUSB_ERROR_IO;
}
/* Set the packet data file to be line buffered */
setlinebuf(tmp_hdl->packet_data_file);
LIBUSB_DUMP_LOG_FILE(tmp_hdl, LIBUSB_LOG_LEVEL_DEBUG,
"VID: %04x PID: %04x idx: %d ref: %d\n",