Hi,
I have an application that prints to stderr when debugging is enabled. It
is multithreaded, so stderr gets a lot of concurrent activity. I have
noticed that libusbx output is often broken up, and looking at the
usbi_log_v() function reveals multiple separate calls to the printf
functions.
AFAIK, any modern OS will provide locking versions of the printf functions,
so that calls to the same file or stream are mutually exclusive. libusbx
can be enhanced to ensure it's debug output is never broken up. It would
require the use of a small local buffer in the usbi_log_v function to
construct the formatted log message. Once completely constructed, it can be
dumped to stderr in one *atomic* call.
Obviously a few considerations are:
1) How big should this buffer be to handle all messages? A maximum length
for the header (less the function name) can be computed, but the function
names and message string will be the variable components.
2) If the message is too long, truncation would occur. This is undesirable.
2) This will increase the stack size requirements of a usbi_log_v()
function call.
It is certainly helpful to have clean output, but is there any support for
this idea?
Regards,
Chris Dickens
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel