[Stgt-devel] [PATCH] fix the logging code to use semtimedop instead of semop
FUJITA Tomonori
fujita.tomonori
Sat Jul 12 07:35:02 CEST 2008
We use two processes to avoid spleeping for a long time due to
logging but we have a bug.
This patch converts the main process to use semtimedop instead of
semop since it can't sleep for a long time.
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
usr/log.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/usr/log.c b/usr/log.c
index 4a30f05..c2fce1f 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -235,12 +235,15 @@ static void log_syslog (void * buff)
static void dolog(int prio, const char *fmt, va_list ap)
{
+ struct timespec t;
+
if (is_daemon) {
+ t.tv_sec = 1;
+ t.tv_nsec = 0;
+
la->ops[0].sem_op = -1;
- if (semop(la->semid, la->ops, 1) < 0) {
- syslog(LOG_ERR, "semop up failed");
+ if (semtimedop(la->semid, la->ops, 1, &t) < 0)
return;
- }
log_enqueue(prio, fmt, ap);
--
1.5.5.GIT
More information about the stgt
mailing list