OSSP CVS Repository

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

ossp-pkg/l2/l2_ch_buffer.c 1.26 -> 1.27

--- l2_ch_buffer.c       2001/10/23 10:05:53     1.26
+++ l2_ch_buffer.c       2001/10/26 11:02:01     1.27
@@ -50,6 +50,60 @@
     l2_level_t  level;
 } l2_ch_buffer_t;
 
+/* Sets the VIRTUAL timer to preconfigured value in cfg */
+static int set_alarm(l2_ch_buffer_t *cfg)
+{
+#ifdef HAVE_INET_SETITIMER
+    struct itimerval valtest, valnew;
+
+    /* initialize auto vars before using them */
+    memset(&valnew, 0, sizeof(valnew));
+
+    valnew.it_interval.tv_sec = cfg->bufinterval;
+    valnew.it_interval.tv_usec = 0;
+    valnew.it_value.tv_sec = cfg->bufinterval;
+    valnew.it_value.tv_usec = 0;
+    if  ((getitimer(L2_BUFFER_TIMER, &testval) == 0) &&
+        ((testval.it_value.tv_sec | testval.it_value.tv_usec |
+        testval.it_interval.tv_sec | testval.it_interval.tv_usec) == 0))
+        return setitimer(L2_BUFFER_TIMER, &valnew, &cfg->valprev);
+    else {
+        cfg->bufinterval = -1L; /* mark this timer as broken */
+        assert(FALSE);
+    }
+#else
+    unsigned int uiAlarmed = 0;
+
+    uiAlarmed = alarm(cfg->bufinterval);
+    if (uiAlarmed) {            /* check if SIGALRM is occupied          */
+        alarm(uiAlarmed);       /* ...if so, then hack in the old value  */
+        cfg->bufinterval = -1L; /* ...mark this timer as broken          */
+        assert(FALSE);          /* ...and warn the user about problems   */
+    }
+    return 0;
+#endif
+}
+
+/* Resets the VIRTUAL timer to preconfigured value in cfg */
+static int reset_alarm(l2_ch_buffer_t *cfg)
+{
+#ifdef HAVE_INET_SETITIMER
+    struct itimerval valnew;
+
+    /* initialize auto vars before using them */
+    memset(&valnew, 0, sizeof(valnew));
+
+    valnew.it_interval.tv_sec = cfg->bufinterval;
+    valnew.it_interval.tv_usec = 0;
+    valnew.it_value.tv_sec = cfg->bufinterval;
+    valnew.it_value.tv_usec = 0;
+    return setitimer(L2_BUFFER_TIMER, &valnew, 0);
+#else
+    alarm(cfg->bufinterval);
+    return 0;
+#endif
+}
+
 static void catchsignal(int sig, ...)
 {
     va_list ap;
@@ -120,66 +174,6 @@
     return rv;
 }
 
-/************************************************************
- * set_alarm: Helper method to hook_open                    *
- *   Sets the VIRTUAL timer to preconfigured value in cfg   *
- ************************************************************/
-static int set_alarm(l2_ch_buffer_t *cfg)
-{
-#ifdef HAVE_INET_SETITIMER
-    struct itimerval valtest, valnew;
-
-    /* initialize auto vars before using them */
-    memset(&valnew, 0, sizeof(valnew));
-
-    valnew.it_interval.tv_sec = cfg->bufinterval;
-    valnew.it_interval.tv_usec = 0;
-    valnew.it_value.tv_sec = cfg->bufinterval;
-    valnew.it_value.tv_usec = 0;
-    if  ((getitimer(L2_BUFFER_TIMER, &testval) == 0) &&
-        ((testval.it_value.tv_sec | testval.it_value.tv_usec |
-        testval.it_interval.tv_sec | testval.it_interval.tv_usec) == 0))
-        return setitimer(L2_BUFFER_TIMER, &valnew, &cfg->valprev);
-    else {
-        cfg->bufinterval = -1L; /* mark this timer as broken */
-        assert(FALSE);
-    }
-#else
-    unsigned int uiAlarmed = 0;
-
-    uiAlarmed = alarm(cfg->bufinterval);
-    if (uiAlarmed) {            /* check if SIGALRM is occupied          */
-        alarm(uiAlarmed);       /* ...if so, then hack in the old value  */
-        cfg->bufinterval = -1L; /* ...mark this timer as broken          */
-        assert(FALSE);          /* ...and warn the user about problems   */
-    }
-    return 0;
-#endif
-}
-
-/************************************************************
- * reset_alarm: Helper method to hook_flush                 *
- *   Resets the VIRTUAL timer to preconfigured value in cfg *
- ************************************************************/
-static int reset_alarm(l2_ch_buffer_t *cfg)
-{
-#ifdef HAVE_INET_SETITIMER
-    struct itimerval valnew;
-
-    /* initialize auto vars before using them */
-    memset(&valnew, 0, sizeof(valnew));
-
-    valnew.it_interval.tv_sec = cfg->bufinterval;
-    valnew.it_interval.tv_usec = 0;
-    valnew.it_value.tv_sec = cfg->bufinterval;
-    valnew.it_value.tv_usec = 0;
-    return setitimer(L2_BUFFER_TIMER, &valnew, 0);
-#else
-    alarm(cfg->bufinterval);
-    return 0;
-#endif
-}
-
 /* open channel */
 static l2_result_t hook_open(l2_context_t *ctx, l2_channel_t *ch)
 {

CVSTrac 2.0.1