diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-01-20 15:40:04 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-01-20 15:40:04 +0000 |
commit | 3c6540b517a45ab540dd120112a44c675fb567ca (patch) | |
tree | 01ddd136759eb7555cbe1d2e332a1f53cbd69f67 /src/mesh | |
parent | 557f97011bc9c0f01f12217e683e78344dc46bf3 (diff) | |
download | gnunet-3c6540b517a45ab540dd120112a44c675fb567ca.tar.gz gnunet-3c6540b517a45ab540dd120112a44c675fb567ca.zip |
Don't call cleaner on tunnels explicity destroyed. Updated and improved documentation.
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/mesh_api.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 924b484df..9b63ceca3 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -370,11 +370,12 @@ create_tunnel (struct GNUNET_MESH_Handle *h, MESH_TunnelNumber tid) | |||
370 | * - Frees all memory used | 370 | * - Frees all memory used |
371 | * | 371 | * |
372 | * @param t Pointer to the tunnel. | 372 | * @param t Pointer to the tunnel. |
373 | * @param call_handler Whether to call the cleaner handler. | ||
373 | * | 374 | * |
374 | * @return Handle to the required tunnel or NULL if not found. | 375 | * @return Handle to the required tunnel or NULL if not found. |
375 | */ | 376 | */ |
376 | static void | 377 | static void |
377 | destroy_tunnel (struct GNUNET_MESH_Tunnel *t) | 378 | destroy_tunnel (struct GNUNET_MESH_Tunnel *t, int call_cleaner) |
378 | { | 379 | { |
379 | struct GNUNET_MESH_Handle *h; | 380 | struct GNUNET_MESH_Handle *h; |
380 | struct GNUNET_PeerIdentity pi; | 381 | struct GNUNET_PeerIdentity pi; |
@@ -425,7 +426,7 @@ destroy_tunnel (struct GNUNET_MESH_Tunnel *t) | |||
425 | } | 426 | } |
426 | if (t->npeers > 0) | 427 | if (t->npeers > 0) |
427 | GNUNET_free (t->peers); | 428 | GNUNET_free (t->peers); |
428 | if (NULL != h->cleaner && 0 != t->owner) | 429 | if (NULL != h->cleaner && 0 != t->owner && GNUNET_YES == call_cleaner) |
429 | h->cleaner (h->cls, t, t->ctx); | 430 | h->cleaner (h->cls, t, t->ctx); |
430 | if (0 != t->owner) | 431 | if (0 != t->owner) |
431 | GNUNET_PEER_change_rc (t->owner, -1); | 432 | GNUNET_PEER_change_rc (t->owner, -1); |
@@ -821,7 +822,7 @@ process_tunnel_destroy (struct GNUNET_MESH_Handle *h, | |||
821 | #if MESH_API_DEBUG | 822 | #if MESH_API_DEBUG |
822 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %u destroyed\n", t->tid); | 823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: tunnel %u destroyed\n", t->tid); |
823 | #endif | 824 | #endif |
824 | destroy_tunnel (t); | 825 | destroy_tunnel (t, GNUNET_YES); |
825 | return; | 826 | return; |
826 | } | 827 | } |
827 | 828 | ||
@@ -929,7 +930,7 @@ process_incoming_data (struct GNUNET_MESH_Handle *h, | |||
929 | t = retrieve_tunnel (h, ntohl (to_orig->tid)); | 930 | t = retrieve_tunnel (h, ntohl (to_orig->tid)); |
930 | payload = (struct GNUNET_MessageHeader *) &to_orig[1]; | 931 | payload = (struct GNUNET_MessageHeader *) &to_orig[1]; |
931 | peer = &to_orig->sender; | 932 | peer = &to_orig->sender; |
932 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: reply on tunnel %s [%x]\n", | 933 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "mesh: torig on tunnel %s [%x]\n", |
933 | GNUNET_i2s (peer), ntohl (to_orig->tid)); | 934 | GNUNET_i2s (peer), ntohl (to_orig->tid)); |
934 | break; | 935 | break; |
935 | default: | 936 | default: |
@@ -1210,7 +1211,9 @@ send_packet (struct GNUNET_MESH_Handle *h, | |||
1210 | * @param cls closure for the various callbacks that follow | 1211 | * @param cls closure for the various callbacks that follow |
1211 | * (including handlers in the handlers array) | 1212 | * (including handlers in the handlers array) |
1212 | * @param new_tunnel function called when an *inbound* tunnel is created | 1213 | * @param new_tunnel function called when an *inbound* tunnel is created |
1213 | * @param cleaner function called when an *inbound* tunnel is destroyed | 1214 | * @param cleaner function called when an *inbound* tunnel is destroyed by the |
1215 | * remote peer, it is *not* called if GNUNET_MESH_tunnel_destroy | ||
1216 | * is called on the tunnel | ||
1214 | * @param handlers callbacks for messages we care about, NULL-terminated | 1217 | * @param handlers callbacks for messages we care about, NULL-terminated |
1215 | * note that the mesh is allowed to drop notifications about | 1218 | * note that the mesh is allowed to drop notifications about |
1216 | * inbound messages if the client does not process them fast | 1219 | * inbound messages if the client does not process them fast |
@@ -1259,7 +1262,10 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1259 | 1262 | ||
1260 | 1263 | ||
1261 | /** | 1264 | /** |
1262 | * Disconnect from the mesh service. | 1265 | * Disconnect from the mesh service. All tunnels will be destroyed. All tunnel |
1266 | * disconnect callbacks will be called on any still connected peers, notifying | ||
1267 | * about their disconnection. The registered inbound tunnel cleaner will be | ||
1268 | * called should any inbound tunnels still exist. | ||
1263 | * | 1269 | * |
1264 | * @param handle connection to mesh to disconnect | 1270 | * @param handle connection to mesh to disconnect |
1265 | */ | 1271 | */ |
@@ -1268,13 +1274,12 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
1268 | { | 1274 | { |
1269 | struct GNUNET_MESH_Tunnel *t; | 1275 | struct GNUNET_MESH_Tunnel *t; |
1270 | struct GNUNET_MESH_Tunnel *aux; | 1276 | struct GNUNET_MESH_Tunnel *aux; |
1271 | struct GNUNET_MESH_TransmitHandle *th; | ||
1272 | 1277 | ||
1273 | t = handle->tunnels_head; | 1278 | t = handle->tunnels_head; |
1274 | while (NULL != t) | 1279 | while (NULL != t) |
1275 | { | 1280 | { |
1276 | aux = t->next; | 1281 | aux = t->next; |
1277 | destroy_tunnel (t); | 1282 | destroy_tunnel (t, GNUNET_YES); |
1278 | t = aux; | 1283 | t = aux; |
1279 | } | 1284 | } |
1280 | while ( (th = handle->th_head) != NULL) | 1285 | while ( (th = handle->th_head) != NULL) |
@@ -1291,6 +1296,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
1291 | GNUNET_CONTAINER_DLL_remove (handle->th_head, handle->th_tail, th); | 1296 | GNUNET_CONTAINER_DLL_remove (handle->th_head, handle->th_tail, th); |
1292 | GNUNET_free (th); | 1297 | GNUNET_free (th); |
1293 | } | 1298 | } |
1299 | |||
1294 | if (NULL != handle->th) | 1300 | if (NULL != handle->th) |
1295 | { | 1301 | { |
1296 | GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); | 1302 | GNUNET_CLIENT_notify_transmit_ready_cancel (handle->th); |
@@ -1337,7 +1343,8 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, void *tunnel_ctx, | |||
1337 | 1343 | ||
1338 | 1344 | ||
1339 | /** | 1345 | /** |
1340 | * Destroy an existing tunnel. | 1346 | * Destroy an existing tunnel. The existing callback for the tunnel will NOT |
1347 | * be called. | ||
1341 | * | 1348 | * |
1342 | * @param tunnel tunnel handle | 1349 | * @param tunnel tunnel handle |
1343 | */ | 1350 | */ |
@@ -1353,7 +1360,7 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel) | |||
1353 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); | 1360 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); |
1354 | msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); | 1361 | msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); |
1355 | msg.tunnel_id = htonl (tunnel->tid); | 1362 | msg.tunnel_id = htonl (tunnel->tid); |
1356 | destroy_tunnel (tunnel); | 1363 | destroy_tunnel (tunnel, GNUNET_NO); |
1357 | send_packet (h, &msg.header); | 1364 | send_packet (h, &msg.header); |
1358 | } | 1365 | } |
1359 | 1366 | ||