Hi there!
I never thought about this... until now: I'm using libssh in a multithreaded
application and I'm logging from within the threads, using the lib's logging
functions.
I'm quite sure that this isn't an issue as long as the output goes to stderr.
But I added a callback (ssh_set_log_callback) which writes the messages to a
file handle, like:
logging_cb( ... )
{
fprintf(log_fd, "[%s, %d] %s - %sn", date, verbosity, (char *)userdata,
buffer);
fflush(log_fd);
}
fprintf() is thread-safe. But can it block? In other words: Could one thread
temporarily block another because of the logging?
So far I couldn't observe any blocking. But to be honest, I'm not sure why it
works fine.
Maybe the OS layer write buffer is simply big enough to "take it all"?
Cheers
Till