From e30105c9f36687e49952a20132d45eee99c931b6 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 1 Sep 2011 14:28:19 +0000 Subject: [PATCH] Changed add_peer to drop timeout, updated documentation, minor fixes --- src/mesh/gnunet-service-mesh.c | 4 +-- src/mesh/mesh_api_new.c | 45 +++------------------------------- 2 files changed, 6 insertions(+), 43 deletions(-) diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 71d611287..0f8f2732f 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -812,7 +812,7 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) { - announce_applications_task = (GNUNET_SCHEDULER_TaskIdentifier) 0; + announce_applications_task = GNUNET_SCHEDULER_NO_TASK; return; } p = (unsigned int *) &buffer[8]; @@ -855,7 +855,7 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) { - announce_id_task = (GNUNET_SCHEDULER_TaskIdentifier) 0; + announce_id_task = GNUNET_SCHEDULER_NO_TASK; return; } GNUNET_PEER_resolve (myid, &id); diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index 008cac029..3dee03c20 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c @@ -221,10 +221,6 @@ struct GNUNET_MESH_Peer */ int connected; - /** - * Task to cancel the connection request for this peer - */ - GNUNET_SCHEDULER_TaskIdentifier cancel; }; @@ -404,29 +400,6 @@ timeout_transmission (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -/** - * Notify client that the transmission has timed out - * @param cls closure - * @param tc task context - */ -static void -timeout_peer_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) -{ - struct GNUNET_MESH_Peer *p = cls; - struct GNUNET_PeerIdentity id; - - GNUNET_assert (0 == p->connected); - remove_peer_from_tunnel (p); - - if (NULL != p->t->connect_handler) - /* FIXME: change handler spec to allow send info about WHO timed out */ - p->t->connect_handler (p->t->cls, 0, NULL); - - GNUNET_PEER_resolve (p->id, &id); - GNUNET_MESH_peer_request_connect_del (p->t, &id); - GNUNET_free (p); -} - /** * Add a transmit handle to the transmission queue by priority and set the * timeout if needed. @@ -476,10 +449,7 @@ process_tunnel_create (struct GNUNET_MESH_Handle *h, tid = ntohl (msg->tunnel_id); if (tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK) { - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "MESH: received an incoming tunnel with tid in local range (%X)\n", - tid); - GNUNET_break_op (0); + GNUNET_break (0); return; //FIXME abort? reconnect? } t = GNUNET_malloc (sizeof (struct GNUNET_MESH_Tunnel)); @@ -529,11 +499,6 @@ process_peer_event (struct GNUNET_MESH_Handle *h, { t->connect_handler (t->cls, &msg->peer, &atsi); } - if (GNUNET_SCHEDULER_NO_TASK != p->cancel) - { - GNUNET_SCHEDULER_cancel (p->cancel); - p->cancel = GNUNET_SCHEDULER_NO_TASK; - } p->connected = 1; } else @@ -590,12 +555,12 @@ process_incoming_data (struct GNUNET_MESH_Handle *h, peer = &to_orig->sender; break; default: - GNUNET_break_op (0); + GNUNET_break (0); return; } if (NULL == t) { - GNUNET_break_op (0); + GNUNET_break (0); return; } for (i = 0; i < h->n_handlers; i++) @@ -975,7 +940,7 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tun) * Request that a peer should be added to the tunnel. The existing * connect handler will be called ONCE with either success or failure. * This function should NOT be called again with the same peer before the - * connect handler is called + * connect handler is called. * * @param tunnel handle to existing tunnel * @param timeout how long to try to establish a connection @@ -983,7 +948,6 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tun) */ void GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel, - struct GNUNET_TIME_Relative timeout, const struct GNUNET_PeerIdentity *peer) { struct GNUNET_MESH_PeerControl msg; @@ -1002,7 +966,6 @@ GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel, } } p = add_peer_to_tunnel (tunnel, peer); - p->cancel = GNUNET_SCHEDULER_add_delayed (timeout, &timeout_peer_request, p); msg.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_CONNECT_PEER_ADD); -- 2.25.1