OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_ch_buffer.c versions 1.22 and 1.23
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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)

CVSTrac 2.0.1