From e07f6311788307d06d907952a8686add4f0cc16b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 17 Feb 2010 16:32:11 +0000 Subject: [PATCH] timeout --- src/core/core.h | 7 ++++++- src/core/core_api_peer_request.c | 7 +++++++ src/core/gnunet-service-core.c | 14 ++++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/core/core.h b/src/core/core.h index 4b59498bd..d74ee06f6 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -29,7 +29,7 @@ /** * General core debugging. */ -#define DEBUG_CORE GNUNET_NO +#define DEBUG_CORE GNUNET_YES /** * Debugging interaction core-clients. @@ -328,6 +328,11 @@ struct ConnectMessage */ uint32_t reserved GNUNET_PACKED; + /** + * When to time out. + */ + struct GNUNET_TIME_RelativeNBO timeout; + /** * Identity of the other peer. */ diff --git a/src/core/core_api_peer_request.c b/src/core/core_api_peer_request.c index 7a76a91df..008393227 100644 --- a/src/core/core_api_peer_request.c +++ b/src/core/core_api_peer_request.c @@ -56,6 +56,11 @@ struct GNUNET_CORE_PeerRequestHandle */ void *cont_cls; + /** + * When to time out. + */ + struct GNUNET_TIME_Absolute timeout; + /** * Identity of the peer to connect to. */ @@ -98,6 +103,7 @@ send_request (void *cls, msg.header.type = htons (prh->type); msg.header.size = htons (sizeof (struct ConnectMessage)); msg.reserved = htonl (0); + msg.timeout = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (prh->timeout)); msg.peer = prh->peer; memcpy (buf, &msg, sizeof (msg)); GNUNET_SCHEDULER_add_continuation (prh->sched, @@ -149,6 +155,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched, ret->cont_cls = cont_cls; ret->peer = *peer; ret->type = GNUNET_MESSAGE_TYPE_CORE_REQUEST_CONNECT; + ret->timeout = GNUNET_TIME_relative_to_absolute (timeout); GNUNET_CLIENT_notify_transmit_ready (client, sizeof (struct ConnectMessage), timeout, diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index f44346011..afb7095d9 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -2045,8 +2045,13 @@ static size_t notify_transport_connect_done (void *cls, size_t size, void *buf) { struct Neighbour *n = cls; + struct GNUNET_MessageHeader hdr; + n->th = NULL; - return 0; + hdr.type = htons (GNUNET_MESSAGE_TYPE_TOPOLOGY_DUMMY); + hdr.size = htons (sizeof(hdr)); + memcpy (buf, &hdr, sizeof (hdr)); + return sizeof (hdr); } @@ -2064,6 +2069,7 @@ handle_client_request_connect (void *cls, { const struct ConnectMessage *cm = (const struct ConnectMessage*) message; struct Neighbour *n; + struct GNUNET_TIME_Relative timeout; GNUNET_SERVER_receive_done (client, GNUNET_OK); n = find_neighbour (&cm->peer); @@ -2078,12 +2084,12 @@ handle_client_request_connect (void *cls, "REQUEST_CONNECT", GNUNET_i2s (&cm->peer)); #endif + timeout = GNUNET_TIME_relative_ntoh (cm->timeout); /* ask transport to connect to the peer */ - /* FIXME: timeout zero OK? */ n->th = GNUNET_TRANSPORT_notify_transmit_ready (transport, &cm->peer, - 0, 0, - GNUNET_TIME_UNIT_ZERO, + sizeof (struct GNUNET_MessageHeader), 0, + timeout, ¬ify_transport_connect_done, n); GNUNET_break (NULL != n->th); -- 2.25.1