-fix
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 18 Jun 2012 09:07:38 +0000 (09:07 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 18 Jun 2012 09:07:38 +0000 (09:07 +0000)
src/transport/gnunet-service-transport.c
src/transport/gnunet-service-transport_neighbours.c
src/transport/gnunet-service-transport_neighbours.h

index 1714229b53d1f7bf46c267be1a3c3105193eb328..b2b59c8e2c585fc04dd5246f3d4d25ff25211f6a 100644 (file)
@@ -339,6 +339,7 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
 {
   const char *transport_name = cls;
   struct GNUNET_HELLO_Address address;
+  int ret;
 
   GNUNET_assert (strlen (transport_name) > 0);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Session %p to peer `%s' ended \n",
@@ -352,8 +353,13 @@ plugin_env_session_end (void *cls, const struct GNUNET_PeerIdentity *peer,
   address.address = NULL;
   address.address_length = 0;
   address.transport_name = transport_name;
-  GST_neighbours_session_terminated (peer, session);
-  GNUNET_ATS_address_destroyed (GST_ats, &address, session);
+  ret = GST_neighbours_session_terminated (peer, session);
+  if (GNUNET_NO == ret)
+  {
+    /* This was a session currently not used by
+     * neighbours so we have to destroy it here */
+    GNUNET_ATS_address_destroyed (GST_ats, &address, session);
+  }
 }
 
 
index 44b9338adeeb1d15f8aa32e71b705757490d158e..78e160fa0eb19734aadf5fb1eef7e3ecd2a52240 100644 (file)
@@ -766,6 +766,7 @@ free_address (struct NeighbourAddress *na)
   {
     GST_validation_set_address_use (na->address, na->session, GNUNET_NO, __LINE__);
     GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_NO);
+    GNUNET_ATS_address_destroyed (GST_ats, na->address, na->session);
   }
   na->ats_active = GNUNET_NO;
   if (NULL != na->address)
@@ -2681,8 +2682,10 @@ GST_neighbours_handle_connect_ack (const struct GNUNET_MessageHeader *message,
  *
  * @param peer identity of the peer where the session died
  * @param session session that is gone
+ * @param GNUNET_YES if this was a session used, GNUNET_NO if
+ *        this session was not in use
  */
-void
+int
 GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
                                    struct Session *session)
 {
@@ -2706,7 +2709,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
     }
   }
   if (NULL == (n = lookup_neighbour (peer)))
-    return; /* can't affect us */
+    return GNUNET_NO; /* can't affect us */
   if (session != n->primary_address.session)
   {
     if (session == n->alternative_address.session)
@@ -2718,7 +2721,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
       else
        GNUNET_break (0);
     }
-    return; /* doesn't affect us further */
+    return GNUNET_NO; /* doesn't affect us further */
   }
 
   n->expect_latency_response = GNUNET_NO;
@@ -2727,11 +2730,11 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
   case S_NOT_CONNECTED:
     GNUNET_break (0);
     free_neighbour (n, GNUNET_NO);
-    return;
+    return GNUNET_YES;
   case S_INIT_ATS:
     GNUNET_break (0);
     free_neighbour (n, GNUNET_NO);
-    return;
+    return GNUNET_YES;
   case S_INIT_BLACKLIST:
   case S_CONNECT_SENT:
     free_address (&n->primary_address);
@@ -2747,7 +2750,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
     /* error on inbound session; free neighbour entirely */
     free_address (&n->primary_address);
     free_neighbour (n, GNUNET_NO);
-    return;
+    return GNUNET_YES;
   case S_CONNECTED:
     free_address (&n->primary_address);
     n->state = S_RECONNECT_ATS;
@@ -2798,6 +2801,7 @@ GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
   if (GNUNET_SCHEDULER_NO_TASK != n->task)
     GNUNET_SCHEDULER_cancel (n->task);
   n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
+  return GNUNET_YES;
 }
 
 
index 23091b75065a1a5d8211b8225b578e42e29ce63e..c53f1a457648aafe00b44fb3b486bbf8d0603a60 100644 (file)
@@ -195,8 +195,10 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, void *cb_cls);
  *
  * @param peer identity of the peer where the session died
  * @param session session that is gone
+ * @param GNUNET_YES if this was a session used, GNUNET_NO if
+ *        this session was not in use
  */
-void
+int
 GST_neighbours_session_terminated (const struct GNUNET_PeerIdentity *peer,
                                    struct Session *session);