gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5240 - in GNUnet/src: include transports util/network


From: gnunet
Subject: [GNUnet-SVN] r5240 - in GNUnet/src: include transports util/network
Date: Wed, 4 Jul 2007 23:42:04 -0600 (MDT)

Author: grothoff
Date: 2007-07-04 23:42:04 -0600 (Wed, 04 Jul 2007)
New Revision: 5240

Modified:
   GNUnet/src/include/gnunet_util_network.h
   GNUnet/src/transports/tcp.c
   GNUnet/src/transports/tcp_helper.c
   GNUnet/src/util/network/select.c
Log:
faster timeout of idle and unused TCP connections

Modified: GNUnet/src/include/gnunet_util_network.h
===================================================================
--- GNUnet/src/include/gnunet_util_network.h    2007-07-05 02:31:14 UTC (rev 
5239)
+++ GNUnet/src/include/gnunet_util_network.h    2007-07-05 05:42:04 UTC (rev 
5240)
@@ -492,8 +492,18 @@
                   struct SocketHandle * sock,
                   void * sock_ctx);
 
+
 /**
+ * Change the timeout for this socket to a custom
+ * value.  Use 0 to use the default timeout for
+ * this select.
  */
+int select_change_timeout(struct SelectHandle * sh,
+                         struct SocketHandle * sock,
+                         cron_t timeout);
+
+/**
+ */
 int select_update_closure(struct SelectHandle * sh,
                          struct SocketHandle * sock,
                          void * old_sock_ctx,

Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2007-07-05 02:31:14 UTC (rev 5239)
+++ GNUnet/src/transports/tcp.c 2007-07-05 05:42:04 UTC (rev 5240)
@@ -43,6 +43,15 @@
  */
 #define TCP_TIMEOUT (600 * cronSECONDS)
 
+/**
+ * after how much time of the core not being associated with a tcp
+ * connection anymore do we close it?
+ *
+ * Needs to be larger than SECONDS_INACTIVE_DROP in
+ * core's connection.s
+ */
+#define TCP_FAST_TIMEOUT (5 * cronSECONDS)
+
 #define TARGET_BUFFER_SIZE 4092
 
 #include "tcp_helper.c"

Modified: GNUnet/src/transports/tcp_helper.c
===================================================================
--- GNUnet/src/transports/tcp_helper.c  2007-07-05 02:31:14 UTC (rev 5239)
+++ GNUnet/src/transports/tcp_helper.c  2007-07-05 05:42:04 UTC (rev 5240)
@@ -151,6 +151,10 @@
   tcpsession->users--;
   if ( (tcpsession->users > 0) ||
        (tcpsession->in_select == YES) ) {
+    if (tcpsession->users == 0)
+      select_change_timeout(selector,
+                           tcpsession->sock,
+                           TCP_FAST_TIMEOUT);
     MUTEX_UNLOCK(tcpsession->lock);
     MUTEX_UNLOCK(tcplock);
     return OK;
@@ -193,7 +197,13 @@
   GE_ASSERT(ectx, tsession != NULL);
   tcpSession = tsession->internal;
   MUTEX_LOCK(tcpSession->lock);
+  if ( (tcpsession->users == 0) &&
+       (tcpsession->in_select == YES) )
+    select_change_timeout(selector,
+                         tcpsession->sock,
+                         0 /* default */);
   tcpSession->users++;
+  
   MUTEX_UNLOCK(tcpSession->lock);
   return OK;
 }

Modified: GNUnet/src/util/network/select.c
===================================================================
--- GNUnet/src/util/network/select.c    2007-07-05 02:31:14 UTC (rev 5239)
+++ GNUnet/src/util/network/select.c    2007-07-05 05:42:04 UTC (rev 5240)
@@ -58,6 +58,12 @@
   cron_t lastUse;
 
   /**
+   * Set to 0 initially, set to a much lower value
+   * if a "fast timeout" is desired.
+   */
+  cron_t timeout;
+
+  /**
    * 0 : can be destroyed
    * 1 : if destruction is required, it must be delayed
    * -1: delayed destruction required
@@ -758,8 +764,10 @@
        i--;
        continue;
       }
-      if ( (sh->timeout != 0) &&
-          (get_time() > session->lastUse + sh->timeout) ) {
+      if ( ( (sh->timeout != 0) &&
+            (get_time() > session->lastUse + sh->timeout) ) ||
+          ( (session->timeout != 0) &&
+            (get_time() > session->lastUse + session->timeout) ) ) {
        destroySession(sh, session);
        i--;
        continue;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]