From 45849022cee7c67976092cf932497ec7ad326d8f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 18 Jul 2010 23:55:39 +0000 Subject: [PATCH] syslog_sender(): * After an unsuccessful find_port() wait a while before trying again. find_port() is quite expensive and particularly during the boot process it was called quite busily. Essentially a find_port() per written syslog message was performed. * Added TODOs regarding using a semaphore and using find_port(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37571 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/debug/debug.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/system/kernel/debug/debug.cpp b/src/system/kernel/debug/debug.cpp index 96cdfc6762..f2defb629a 100644 --- a/src/system/kernel/debug/debug.cpp +++ b/src/system/kernel/debug/debug.cpp @@ -1190,12 +1190,30 @@ syslog_sender(void* data) // Note: We time out since in some situations output is added to // the syslog buffer without being allowed to notify us (e.g. in // the kernel debugger). + // TODO: A semaphore is rather unhandy here. It is released for + // every single message written to the buffer, but we potentially + // send a lot more than a single message per iteration. On the other + // hand, as long as the syslog daemon is not running, we acquire + // the semaphore anyway. A better solution would be a flag + a + // condition variable. sSyslogMessage->when = real_time_clock(); if (error == B_BAD_PORT_ID) { // last message couldn't be sent, try to locate the syslog_daemon port = find_port(SYSLOG_PORT_NAME); + if (port < 0) { + // Don't recheck too quickly, since find_port) is rather + // expensive. + // TODO: Maybe using the port notification mechanism would be + // the better option here. Alternatively, and probably even + // better, the syslog daemon could register itself via a syscall + // (like the messaging service). We could even wait with + // starting this thread before that happened (end exit as soon + // as the port is gone). + snooze(1000000); + continue; + } } if (port >= B_OK) {