fast timeout on disconnect
authorChristian Grothoff <christian@grothoff.org>
Mon, 19 Jul 2010 12:49:02 +0000 (12:49 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 19 Jul 2010 12:49:02 +0000 (12:49 +0000)
src/core/gnunet-service-core.c
src/include/gnunet_constants.h

index 8cd598e83f0ee3b1ef12619b466dbc453a7e41fc..52724e57870c35eef621310b08691d971bcc2168 100644 (file)
@@ -3717,6 +3717,7 @@ handle_transport_notify_disconnect (void *cls,
 {
   struct DisconnectNotifyMessage cnm;
   struct Neighbour *n;
+  struct GNUNET_TIME_Relative left;
 
 #if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3741,6 +3742,15 @@ handle_transport_notify_disconnect (void *cls,
                            gettext_noop ("# peers connected (transport)"), 
                            -1, 
                            GNUNET_NO);
+  if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
+    GNUNET_SCHEDULER_cancel (sched,
+                            n->dead_clean_task);
+  left = GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT;
+  n->last_activity = GNUNET_TIME_absolute_subtract (GNUNET_TIME_absolute_get (), left);
+  n->dead_clean_task = GNUNET_SCHEDULER_add_delayed (sched,
+                                                    left,
+                                                    &consider_free_task,
+                                                    n);
 }
 
 
index c32add92a8a506046c025fea885b821fc4880dad..56a868e2ee68f6d429fe9f4d9b06676e0216e715 100644 (file)
@@ -51,6 +51,12 @@ extern "C"
  */
 #define GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 
+/**
+ * After how long do we consider a connection to a peer dead
+ * if we got an explicit disconnect and were unable to reconnect?
+ */
+#define GNUNET_CONSTANTS_DISCONNECT_SESSION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+
 /**
  * How long do we delay reading more from a peer after a quota violation?
  */