[Sheepdog] [PATCH 3/3] logger: set SEM_UNDO for semget()
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Sun Aug 14 11:22:52 CEST 2011
If sheep terminates during a logging operation, the sheep logger
cannot get semaphore any more and cannot exit in log_sigsegv(). To
resolve the problem, this patch sets SEM_UNDO for semget().
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
lib/logger.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/logger.c b/lib/logger.c
index 565a397..146b83a 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -293,7 +293,7 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list
ts.tv_nsec = 10000;
ops.sem_num = 0;
- ops.sem_flg = 0;
+ ops.sem_flg = SEM_UNDO;
ops.sem_op = -1;
if (semop(la->semid, &ops, 1) < 0) {
syslog(LOG_ERR, "semop up failed %m");
@@ -344,7 +344,7 @@ static void log_flush(void)
while (!la->empty) {
ops.sem_num = 0;
- ops.sem_flg = 0;
+ ops.sem_flg = SEM_UNDO;
ops.sem_op = -1;
if (semop(la->semid, &ops, 1) < 0) {
syslog(LOG_ERR, "semop up failed");
--
1.7.2.5
More information about the sheepdog
mailing list