gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19282 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r19282 - gnunet/src/mesh
Date: Fri, 20 Jan 2012 16:40:04 +0100

Author: bartpolot
Date: 2012-01-20 16:40:04 +0100 (Fri, 20 Jan 2012)
New Revision: 19282

Modified:
   gnunet/src/mesh/mesh_api.c
Log:
Don't call cleaner on tunnels explicity destroyed. Updated and improved 
documentation.

Modified: gnunet/src/mesh/mesh_api.c
===================================================================
--- gnunet/src/mesh/mesh_api.c  2012-01-20 13:08:24 UTC (rev 19281)
+++ gnunet/src/mesh/mesh_api.c  2012-01-20 15:40:04 UTC (rev 19282)
@@ -370,11 +370,12 @@
  * - Frees all memory used
  *
  * @param t Pointer to the tunnel.
+ * @param call_handler Whether to call the cleaner handler.
  *
  * @return Handle to the required tunnel or NULL if not found.
  */
 static void
-destroy_tunnel (struct GNUNET_MESH_Tunnel *t)
+destroy_tunnel (struct GNUNET_MESH_Tunnel *t, int call_cleaner)
 {
   struct GNUNET_MESH_Handle *h;
   struct GNUNET_PeerIdentity pi;
@@ -425,7 +426,7 @@
   }
   if (t->npeers > 0)
     GNUNET_free (t->peers);
-  if (NULL != h->cleaner && 0 != t->owner)
+  if (NULL != h->cleaner && 0 != t->owner && GNUNET_YES == call_cleaner)
     h->cleaner (h->cls, t, t->ctx);
   if (0 != t->owner)
     GNUNET_PEER_change_rc (t->owner, -1);
@@ -821,7 +822,7 @@
 #if MESH_API_DEBUG
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %u destroyed\n", t->tid);
 #endif
-  destroy_tunnel (t);
+  destroy_tunnel (t, GNUNET_YES);
   return;
 }
 
@@ -929,7 +930,7 @@
     t = retrieve_tunnel (h, ntohl (to_orig->tid));
     payload = (struct GNUNET_MessageHeader *) &to_orig[1];
     peer = &to_orig->sender;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:   reply on tunnel %s [%x]\n",
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh:   torig on tunnel %s [%x]\n",
                 GNUNET_i2s (peer), ntohl (to_orig->tid));
     break;
   default:
@@ -1210,7 +1211,9 @@
  * @param cls closure for the various callbacks that follow
  *            (including handlers in the handlers array)
  * @param new_tunnel function called when an *inbound* tunnel is created
- * @param cleaner function called when an *inbound* tunnel is destroyed
+ * @param cleaner function called when an *inbound* tunnel is destroyed by the
+ *                remote peer, it is *not* called if GNUNET_MESH_tunnel_destroy
+ *                is called on the tunnel
  * @param handlers callbacks for messages we care about, NULL-terminated
  *                note that the mesh is allowed to drop notifications about
  *                inbound messages if the client does not process them fast
@@ -1259,7 +1262,10 @@
 
 
 /**
- * Disconnect from the mesh service.
+ * Disconnect from the mesh service. All tunnels will be destroyed. All tunnel
+ * disconnect callbacks will be called on any still connected peers, notifying
+ * about their disconnection. The registered inbound tunnel cleaner will be
+ * called should any inbound tunnels still exist.
  *
  * @param handle connection to mesh to disconnect
  */
@@ -1268,13 +1274,12 @@
 {
   struct GNUNET_MESH_Tunnel *t;
   struct GNUNET_MESH_Tunnel *aux;
-  struct GNUNET_MESH_TransmitHandle *th;
 
   t = handle->tunnels_head;
   while (NULL != t)
   {
     aux = t->next;
-    destroy_tunnel (t);
+    destroy_tunnel (t, GNUNET_YES);
     t = aux;
   }
   while ( (th = handle->th_head) != NULL)
@@ -1291,6 +1296,7 @@
     GNUNET_CONTAINER_DLL_remove (handle->th_head, handle->th_tail, th);
     GNUNET_free (th);
   }
+
   if (NULL != handle->th)
   {
     GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th);
@@ -1337,7 +1343,8 @@
 
 
 /**
- * Destroy an existing tunnel.
+ * Destroy an existing tunnel. The existing callback for the tunnel will NOT
+ * be called.
  *
  * @param tunnel tunnel handle
  */
@@ -1353,7 +1360,7 @@
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY);
   msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage));
   msg.tunnel_id = htonl (tunnel->tid);
-  destroy_tunnel (tunnel);
+  destroy_tunnel (tunnel, GNUNET_NO);
   send_packet (h, &msg.header);
 }
 




reply via email to

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