[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Logging and Threads
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: Logging and Threads
- From: g4-lisz@xxxxxxxxxxxx
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 04 Mar 2025 20:25:20 +0000
- To: libssh@xxxxxxxxxx
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
Re: Logging and Threads | Marian Beermann <public@xxxxxxxxx> |
Re: Logging and Threads | g4-lisz@xxxxxxxxxxxx |