Index: ossp-pkg/l2/l2_ch_buffer.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_ch_buffer.c,v rcsdiff -q -kk '-r1.24' '-r1.25' -u '/v/ossp/cvs/ossp-pkg/l2/l2_ch_buffer.c,v' 2>/dev/null --- l2_ch_buffer.c 2001/10/12 14:46:17 1.24 +++ l2_ch_buffer.c 2001/10/22 16:32:29 1.25 @@ -53,16 +53,21 @@ static void catchsignal(int sig, ...) { va_list ap; - static l2_channel_t *ch = NULL; + static l2_channel_t *ch = NULL; + static l2_ch_buffer_t *cfg = NULL; if (sig == 0) { va_start(ap, sig); - ch = va_arg(ap, l2_channel_t *); + ch = va_arg(ap, l2_channel_t *); /* init the handler just like */ + cfg = va_arg(ap, l2_ch_buffer_t *); /* Thomas Lotterer does */ va_end(ap); } else if (sig == SIGALRM) { TRACE("SIGALRM caught"); l2_channel_flush(ch); +#ifndef HAVE_SETITIMER + reset_alarm(cfg); /* alarm(3) doesn't auto-reset like setitime(2) */ +#endif } } @@ -130,6 +135,7 @@ valnew.it_value.tv_usec = 0; return setitimer(L2_BUFFER_TIMER, &valnew, &cfg->valprev); #else + alarm(cfg->bufinterval); return 0; #endif } @@ -152,6 +158,7 @@ valnew.it_value.tv_usec = 0; return setitimer(L2_BUFFER_TIMER, &valnew, 0); #else + alarm(cfg->bufinterval); return 0; #endif } @@ -172,7 +179,7 @@ sigemptyset(&locact.sa_mask); locact.sa_flags = 0; - catchsignal(0, ch); + catchsignal(0, ch, (l2_ch_buffer_t *)ctx->vp); /* save old signal context before replacing with our own */ if (sigaction(SIGALRM, &locact, &cfg->sigalrm) < 0) return L2_ERR_SYS; @@ -243,6 +250,7 @@ l2_result_t rv; /* write the buffer contents downstream */ +TRACE("l2_ch_buffer hook_flush called\n"); if (cfg->bufpos > 0) { if ((rv = l2_channel_write(downstream, cfg->level, cfg->buf, cfg->bufpos)) != L2_OK) return rv; Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.33' '-r1.34' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- l2_test.c 2001/10/05 14:25:57 1.33 +++ l2_test.c 2001/10/22 16:32:29 1.34 @@ -57,6 +57,7 @@ int main(int argc, char *argv[]) { + int i; /* For testing l2_stream_log() */ l2_channel_t *chFilt; l2_channel_t *chPrefix; l2_channel_t *chBuf; @@ -220,17 +221,20 @@ if (l2_stream_formatter(st, 'S', l2_util_fmt_dump, NULL) != L2_OK) die("failed to configure formatter for %%S"); - if (l2_stream_log(st, L2_LEVEL_PANIC, "0Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) - die("failed to log message to stream"); - - if (l2_stream_log(st, L2_LEVEL_PANIC, "1Shecking\n") != L2_OK) - die("failed to log message to stream"); - - if (l2_stream_log(st, L2_LEVEL_PANIC, "2Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) - die("failed to log message to stream"); - - if (l2_stream_log(st, L2_LEVEL_PANIC, "3Shecking\n") != L2_OK) - die("failed to log message to stream"); + while (1) { + for (i = 1; i != 0; i++); + if (l2_stream_log(st, L2_LEVEL_PANIC, "0Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) + die("failed to log message to stream"); + + if (l2_stream_log(st, L2_LEVEL_PANIC, "1Shecking\n") != L2_OK) + die("failed to log message to stream"); + + if (l2_stream_log(st, L2_LEVEL_PANIC, "2Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK) + die("failed to log message to stream"); + + if (l2_stream_log(st, L2_LEVEL_PANIC, "3Shecking\n") != L2_OK) + die("failed to log message to stream"); + } if (l2_stream_destroy(st) != L2_OK) die("failed to destroy stream");