[pisa-src] r1328 - in trunk/pisacd: cdctx.c cdctx.h cdmain.c cdpending.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 27 Oct 2009 15:39:06 +0100

Author: tjansen
Date: Tue Oct 27 15:39:05 2009
New Revision: 1328

Log:
Replaced the local variable "pending" in cd_do_main by "cd_ctx.pending".
The variable is used to delay the shutdown of the client daemon until all
pending events have been processed. This brings back the old behavior of
deregistering properly when we get a SIGINT.

Modified:
   trunk/pisacd/cdctx.c
   trunk/pisacd/cdctx.h
   trunk/pisacd/cdmain.c
   trunk/pisacd/cdpending.c

Modified: trunk/pisacd/cdctx.c
==============================================================================
--- trunk/pisacd/cdctx.c        Tue Oct 27 15:34:49 2009        (r1327)
+++ trunk/pisacd/cdctx.c        Tue Oct 27 15:39:05 2009        (r1328)
@@ -30,6 +30,7 @@
 {
        cdctx->is_cd_running = FALSE;
        cdctx->is_bgrun = FALSE;
+       cdctx->pending = 0;
        cdctx->tunnel = -1;
        cdctx->tunc = -1;
        cdctx->tund = -1;

Modified: trunk/pisacd/cdctx.h
==============================================================================
--- trunk/pisacd/cdctx.h        Tue Oct 27 15:34:49 2009        (r1327)
+++ trunk/pisacd/cdctx.h        Tue Oct 27 15:39:05 2009        (r1328)
@@ -38,6 +38,12 @@
        int is_bgrun;
 
        /**
+        * Flag for pending events.
+        * 1: at least one event is pending, 0: no event is pending.
+        */
+       int pending;
+
+       /**
         * Sockets for the tunnel device, the tunc and tund sockets
         */
        int tund;

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Tue Oct 27 15:34:49 2009        (r1327)
+++ trunk/pisacd/cdmain.c       Tue Oct 27 15:39:05 2009        (r1328)
@@ -243,7 +243,6 @@
 static inline void cd_do_main(void)
 {
        int maxfd;
-       int pending = 0;
        fd_set readfds;
 
        cd_ctx.is_cd_running = TRUE;
@@ -255,7 +254,7 @@
        /* TODO Inline this if we can get rid of the ifdef. -- Thomas */
        maxfd = cd_get_maxfd() + 1;
 
-       while (cd_ctx.is_cd_running || pending) {
+       while (cd_ctx.is_cd_running || cd_ctx.pending) {
                /* sockets.tunnel needs to be always included in the reading fd 
list */
                FD_ZERO(&readfds);
                FD_SET(cd_ctx.tunnel, &readfds);

Modified: trunk/pisacd/cdpending.c
==============================================================================
--- trunk/pisacd/cdpending.c    Tue Oct 27 15:34:49 2009        (r1327)
+++ trunk/pisacd/cdpending.c    Tue Oct 27 15:39:05 2009        (r1328)
@@ -82,6 +82,8 @@
        pend->send = send;
        pend->fail = fail;
 
+       cd_ctx.pending = 1;
+
        /* Schedule the first try immediately */
        if (pend->task)
                pisa_sched_remove(&cd_ctx.scheduler, pend->task);
@@ -102,6 +104,8 @@
        if (pend->data != NULL)
                free(pend->data);
        free(pend);
+
+       cd_ctx.pending = (hash_pending == NULL) ? 0 : 1;
 }
 
 /**

Other related posts:

  • » [pisa-src] r1328 - in trunk/pisacd: cdctx.c cdctx.h cdmain.c cdpending.c - Thomas Jansen