[pisa-src] r1789 - in trunk: libpisa/conmgr.c libpisa/conmgr.h pisacd/cdheartbeat.c pisacd/cdregister.c pisacd/cdtimeout.c pisacd/cdtun.c pisasd/sdheartbeat.c pisasd/sdregister.c pisasd/sdtun.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 13:11:48 +0100

Author: tjansen
Date: Thu Nov 26 13:11:48 2009
New Revision: 1789

Log:
Use bool instead of int for the conmgr flags.

Modified:
   trunk/libpisa/conmgr.c
   trunk/libpisa/conmgr.h
   trunk/pisacd/cdheartbeat.c
   trunk/pisacd/cdregister.c
   trunk/pisacd/cdtimeout.c
   trunk/pisacd/cdtun.c
   trunk/pisasd/sdheartbeat.c
   trunk/pisasd/sdregister.c
   trunk/pisasd/sdtun.c

Modified: trunk/libpisa/conmgr.c
==============================================================================
--- trunk/libpisa/conmgr.c      Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/libpisa/conmgr.c      Thu Nov 26 13:11:48 2009        (r1789)
@@ -108,9 +108,9 @@
        entry->type = type;
        entry->control_port = ctrl_port;
        pisa_ipv6_copy(&entry->hit, hit);
-       entry->timeout_flag = 0;
+       entry->timeout_flag = false;
        entry->timeout_task = NULL;
-       entry->heartbeat_flag = 0;
+       entry->heartbeat_flag = false;
        entry->heartbeat_task = NULL;
        entry->status = PISA_CON_DISCONNECTED;
 

Modified: trunk/libpisa/conmgr.h
==============================================================================
--- trunk/libpisa/conmgr.h      Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/libpisa/conmgr.h      Thu Nov 26 13:11:48 2009        (r1789)
@@ -15,6 +15,7 @@
 #define PISA_CONMGR_H
 
 #include <netinet/in.h>
+#include <stdbool.h>
 
 #include "uthash.h"
 #include "global.h"
@@ -55,9 +56,9 @@
        struct sockaddr_in6 saddr_data;
 
        /**
-        * 0 if no data was received since last check, 1 otherwise.
+        * false if no data was received since last check, true otherwise.
         */
-       int heartbeat_flag;
+       bool heartbeat_flag;
 
        /**
         * Current task for the heartbeat
@@ -65,9 +66,9 @@
        pisa_sched_task *heartbeat_task;
 
        /**
-        * 0 if no data was transfered since last check, 1 otherwise.
+        * false if no data was transfered since last check, true otherwise.
         */
-       int timeout_flag;
+       bool timeout_flag;
 
        /**
         * Current task for the timeout

Modified: trunk/pisacd/cdheartbeat.c
==============================================================================
--- trunk/pisacd/cdheartbeat.c  Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisacd/cdheartbeat.c  Thu Nov 26 13:11:48 2009        (r1789)
@@ -100,11 +100,11 @@
 
        /* If we did not receive data in the last window, send a heartbeat to
         * the server. */
-       if (e->heartbeat_flag == 0) {
+       if (!e->heartbeat_flag) {
                pisa_pending *pend;
                pend = pisa_pending_add(e, PISA_PKTTYPE_TUN_HEARTBEAT, 
pisa_send_heartbeat_pend, pisa_send_heartbeat_fail);
        }
 
-       e->heartbeat_flag = 0;
+       e->heartbeat_flag = false;
        e->heartbeat_task = pisa_sched_add(&cd_ctx.scheduler, 
pisa_task_heartbeat, &delay, e);
 }

Modified: trunk/pisacd/cdregister.c
==============================================================================
--- trunk/pisacd/cdregister.c   Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisacd/cdregister.c   Thu Nov 26 13:11:48 2009        (r1789)
@@ -162,13 +162,13 @@
        }
 
        /* Start the timeout task. */
-       entry->timeout_flag = 0;
+       entry->timeout_flag = false;
        delay.tv_sec = cd_cfg.idle_disconnect_delay;
        delay.tv_usec = 0;
        entry->timeout_task = pisa_sched_add(&cd_ctx.scheduler, 
pisa_task_timeout, &delay, entry);
 
        /* Start the heartbeat task. */
-       entry->heartbeat_flag = 0;
+       entry->heartbeat_flag = false;
        delay.tv_sec = PISA_HEARTBEAT_DELAY;
        delay.tv_usec = 0;
        entry->heartbeat_task = pisa_sched_add(&cd_ctx.scheduler, 
pisa_task_heartbeat, &delay, entry);

Modified: trunk/pisacd/cdtimeout.c
==============================================================================
--- trunk/pisacd/cdtimeout.c    Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisacd/cdtimeout.c    Thu Nov 26 13:11:48 2009        (r1789)
@@ -47,7 +47,7 @@
 
        /* Disconnect if no activity took place since the last time we
         * checked. Not that we don't reschedule in that case. */
-       if (e->timeout_flag == 0 && cd_cfg.idle_disconnect_delay > 0) {
+       if (!e->timeout_flag && cd_cfg.idle_disconnect_delay > 0) {
                char buffer[INET6_ADDRSTRLEN];
                inet_ntop(AF_INET6, &e->hit, buffer, sizeof(buffer));
                PISA_INFO("Removing idle connection to %s\n", buffer);
@@ -56,6 +56,6 @@
        }
 
        /* Reset the timeout flag and reschedule */
-       e->timeout_flag = 0;
+       e->timeout_flag = false;
        e->timeout_task = pisa_sched_add(&cd_ctx.scheduler, pisa_task_timeout, 
&delay, e);
 }

Modified: trunk/pisacd/cdtun.c
==============================================================================
--- trunk/pisacd/cdtun.c        Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisacd/cdtun.c        Thu Nov 26 13:11:48 2009        (r1789)
@@ -85,12 +85,12 @@
        } else {
                /* Sending a heartbeat at the next scheduled time is
                 * unnecessary, we already sent some payload. */
-               entry->heartbeat_flag = 1;
+               entry->heartbeat_flag = true;
 
                /* Keep track of the last time this connection was
                 * used. Disconnect after a timeout to save
                 * resources. */
-               entry->timeout_flag = 1;
+               entry->timeout_flag = true;
 
                PISA_DEBUG(PL_DATA, "remote -> local: %i bytes\n", len - 6);
        }
@@ -170,7 +170,7 @@
                        /* Keep track of the last time this connection was
                         * used. Disconnect after a timeout to save
                         * resources. */
-                       entry->timeout_flag = 1;
+                       entry->timeout_flag = true;
 
                        PISA_DEBUG(PL_DATA, "local -> remote: %i bytes\n", len);
                }

Modified: trunk/pisasd/sdheartbeat.c
==============================================================================
--- trunk/pisasd/sdheartbeat.c  Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisasd/sdheartbeat.c  Thu Nov 26 13:11:48 2009        (r1789)
@@ -30,7 +30,7 @@
        /* If we did not receive data or a heartbeat from the client in the
         * last window remove the connection. There is no need to reschedule
         * in that case. */
-       if (e->heartbeat_flag == 0) {
+       if (!e->heartbeat_flag) {
                char buffer[INET6_ADDRSTRLEN];
                inet_ntop(AF_INET6, &e->hit, buffer, sizeof(buffer));
                PISA_INFO("Removing timed out client %s\n", buffer);
@@ -38,7 +38,7 @@
                return;
        }
 
-       e->heartbeat_flag = 0;
+       e->heartbeat_flag = false;
        e->heartbeat_task = pisa_sched_add(&sd_ctx.scheduler, 
pisa_task_heartbeat, &delay, e);
 }
 
@@ -55,7 +55,7 @@
        pisa_conmgr_entry *e = pisa_conmgr_findby_hit(sd_ctx.conlist, 
&addr->sin6_addr);
 
        if (e) {
-               e->heartbeat_flag = 1;
+               e->heartbeat_flag = true;
                pisa_send_control_packet_ipv6_type(sd_ctx.fd_control, addr, 
PISA_PKTTYPE_TUN_HEARTBEAT_ACK);
                inet_ntop(AF_INET6, &addr->sin6_addr, buffer, sizeof(buffer));
                PISA_INFO("Heartbeat from client %s\n", buffer);

Modified: trunk/pisasd/sdregister.c
==============================================================================
--- trunk/pisasd/sdregister.c   Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisasd/sdregister.c   Thu Nov 26 13:11:48 2009        (r1789)
@@ -55,7 +55,7 @@
        entry->status = PISA_CON_CONNECTED;
 
        /* start the heartbeat task for this connection */
-       entry->heartbeat_flag = 0;
+       entry->heartbeat_flag = false;
        delay.tv_sec = PISA_HEARTBEAT_DELAY;
        delay.tv_usec = 0;
        entry->heartbeat_task = pisa_sched_add(&sd_ctx.scheduler, 
pisa_task_heartbeat, &delay, entry);

Modified: trunk/pisasd/sdtun.c
==============================================================================
--- trunk/pisasd/sdtun.c        Thu Nov 26 12:38:22 2009        (r1788)
+++ trunk/pisasd/sdtun.c        Thu Nov 26 13:11:48 2009        (r1789)
@@ -75,7 +75,7 @@
                srcaddr = (struct in_addr *)&hdr->ip_src;
 
                /* Update the timeout for the connection */
-               entry->heartbeat_flag = 1;
+               entry->heartbeat_flag = true;
 
                if (entry->type == PISA_CONTYPE_LEGACY_ROUTER) {
                        map = pisa_nat_mapping_find_by_mac(sd_ctx.natlist, mac);

Other related posts:

  • » [pisa-src] r1789 - in trunk: libpisa/conmgr.c libpisa/conmgr.h pisacd/cdheartbeat.c pisacd/cdregister.c pisacd/cdtimeout.c pisacd/cdtun.c pisasd/sdheartbeat.c pisasd/sdregister.c pisasd/sdtun.c - Thomas Jansen