OSSP CVS Repository

ossp - Check-in [1082]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1082
Date: 2001-Oct-05 16:25:57 (local)
2001-Oct-05 14:25:57 (UTC)
User:ms
Branch:
Comment: Changed timer from VIRTUAL to REAL. Completed flush alarm mechanism which seems to work, probably because we are not forking.
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_ch_buffer.c      1.22 -> 1.23     15 inserted, 4 deleted
ossp-pkg/l2/l2_test.c      1.32 -> 1.33     11 inserted, 2 deleted

ossp-pkg/l2/l2_ch_buffer.c 1.22 -> 1.23

--- l2_ch_buffer.c       2001/10/05 10:40:17     1.22
+++ l2_ch_buffer.c       2001/10/05 14:25:57     1.23
@@ -48,8 +48,18 @@
 
 static void catchsignal(int sig, ...)
 {
-    if (sig == SIGALRM)
+    va_list ap;
+    static  l2_channel_t *ch = NULL;
+
+    if (sig == 0) {
+        va_start(ap, sig);
+        ch = va_arg(ap, l2_channel_t *);
+        va_end(ap);
+    }
+    else if (sig == SIGALRM) {
         TRACE("SIGALRM caught");
+        l2_channel_flush(ch);
+    }
 }
 
 /* create channel */
@@ -111,7 +121,7 @@
     valnew.it_interval.tv_usec = 0;
     valnew.it_value.tv_sec = cfg->bufinterval;
     valnew.it_value.tv_usec = 0;
-    return setitimer(ITIMER_VIRTUAL, &valnew, &cfg->valprev); /* set flush timer */
+    return setitimer(ITIMER_REAL, &valnew, &cfg->valprev); /* set flush timer */
 }
 
 /************************************************************
@@ -129,7 +139,7 @@
     valnew.it_interval.tv_usec = 0;
     valnew.it_value.tv_sec = cfg->bufinterval;
     valnew.it_value.tv_usec = 0;
-    return setitimer(ITIMER_VIRTUAL, &valnew, 0); /* reset flush timer */
+    return setitimer(ITIMER_REAL, &valnew, 0); /* reset flush timer */
 }
 
 /* open channel */
@@ -148,6 +158,7 @@
         sigemptyset(&locact.sa_mask);
         locact.sa_flags = 0;
 
+        catchsignal(0, ch);
         /* save old signal context before replacing with our own */
         if (sigaction(SIGALRM, &locact, &cfg->sigalrm) < 0)
             return L2_ERR_SYS;
@@ -245,7 +256,7 @@
     l2_result_t rv;
 
     if (cfg->bufinterval != 0) {
-        setitimer(ITIMER_VIRTUAL, &cfg->valprev, 0); /* restore timer values */
+        setitimer(ITIMER_REAL, &cfg->valprev, 0); /* restore timer values */
         /* restore previous signal context if previously saved & replaced    */
         if (&cfg->sigalrm.sa_handler)
             if (sigaction(SIGALRM, &cfg->sigalrm, 0) < 0)


ossp-pkg/l2/l2_test.c 1.32 -> 1.33

--- l2_test.c    2001/10/05 10:40:17     1.32
+++ l2_test.c    2001/10/05 14:25:57     1.33
@@ -99,7 +99,7 @@
     if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL)    /* Buffer */
         die("failed to create buffer channel");
 
-    if (l2_channel_configure(chBuf, "size,interval", 100, 20) != L2_OK)
+    if (l2_channel_configure(chBuf, "size,interval", 800, 12) != L2_OK)
         die("failed to configure buffer channel");
 
     if ((chFile = l2_channel_create(&l2_handler_file)) == NULL)      /* File   */
@@ -220,7 +220,16 @@
     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, "Checking localhost %s %{myparm}k <%{text}S><%{hex}S><%{base64}S>\n", "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7) != L2_OK)
+    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)

CVSTrac 2.0.1