From: Christian Grothoff Date: Wed, 20 Jan 2010 21:06:42 +0000 (+0000) Subject: fixing non-transport compilation issues X-Git-Tag: initial-import-from-subversion-38251~22916 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e6976d9aadb2e6cc4005d33174688c3d86416ed2;p=oweals%2Fgnunet.git fixing non-transport compilation issues --- diff --git a/TODO b/TODO index 5f031772a..5d5f33234 100644 --- a/TODO +++ b/TODO @@ -13,11 +13,19 @@ away), in order in which they will likely be done: Urgent items (before announcing ng.gnunet.org): * CORE: + - update core API to reflect changes to transport API + (need to pass distance to clients!) - test currently fails spectacularly - request disconnect not implemented (needs better transport API) * topology - (forced) disconnect does not work (also CORE API issue) - needs testing (not sure the current testcase does much...) +* testing: + - timeout_hello_task is not used but should be (so we can fail + properly) + - check that 'GNUNET_TRANSPORT_get_hello' is associated with + a TIMEOUT task wherever else appropriate (other testcases + in particular!) * hostlist - test fails (looks like it works, but that's because of a bad connectivity notification; somehow core is unable to send diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 71771905e..0f4a3c3b9 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c @@ -2880,16 +2880,18 @@ handle_encrypted_message (struct Neighbour *n, * Function called by the transport for each received message. * * @param cls closure - * @param latency estimated latency for communicating with the - * given peer * @param peer (claimed) identity of the other peer * @param message the message + * @param latency estimated latency for communicating with the + * given peer (round-trip) + * @param distance in overlay hops, as given by transport plugin */ static void handle_transport_receive (void *cls, - struct GNUNET_TIME_Relative latency, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message) + const struct GNUNET_MessageHeader *message, + struct GNUNET_TIME_Relative latency, + unsigned int distance) { struct Neighbour *n; struct GNUNET_TIME_Absolute now; @@ -3073,11 +3075,13 @@ neighbour_quota_update (void *cls, * @param cls closure * @param peer the peer that connected * @param latency current latency of the connection + * @param distance in overlay hops, as given by transport plugin */ static void handle_transport_notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer, - struct GNUNET_TIME_Relative latency) + struct GNUNET_TIME_Relative latency, + unsigned int distance) { struct Neighbour *n; struct GNUNET_TIME_Absolute now; diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index acece6545..7cb5e245c 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -243,16 +243,14 @@ init_notify (void *cls, static void process_hello (void *cls, - struct GNUNET_TIME_Relative latency, - const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message) { struct PeerContext *p = cls; - GNUNET_assert (peer != NULL); + GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received (my) `%s' from transport service of `%4s'\n", - "HELLO", GNUNET_i2s (peer)); + "Received (my) `%s' from transport service\n", + "HELLO"); GNUNET_assert (message != NULL); p->hello = GNUNET_malloc (ntohs (message->size)); memcpy (p->hello, message, ntohs (message->size)); @@ -285,7 +283,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) GNUNET_ARM_start_services (p->cfg, sched, "core", NULL); p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); - GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p); + GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 904990a83..f9d2e9169 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c @@ -95,11 +95,13 @@ timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * @param cls closure * @param peer the peer that connected * @param latency current latency of the connection + * @param distance in overlay hops, as given by transport plugin */ static void notify_connect (void *cls, const struct GNUNET_PeerIdentity * peer, - struct GNUNET_TIME_Relative latency) + struct GNUNET_TIME_Relative latency, + unsigned int distance) { if (peer == NULL) return; @@ -120,14 +122,11 @@ notify_connect (void *cls, static void process_hello (void *cls, - struct GNUNET_TIME_Relative latency, - const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message) { struct PeerContext *p = cls; - if (message == NULL) - return; + GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received HELLO, starting hostlist service.\n"); GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL); @@ -151,7 +150,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, ¬ify_connect, NULL); GNUNET_assert (p->th != NULL); - GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p); + GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); } diff --git a/src/testing/testing.c b/src/testing/testing.c index 489252411..628856b21 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -973,34 +973,41 @@ transmit_ready (void *cls, size_t size, void *buf) } +#if 0 +static void +timeout_hello_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th, + &process_hello, + ctx); + GNUNET_TRANSPORT_disconnect (ctx->d1th); + GNUNET_TRANSPORT_disconnect (ctx->d2th); + if (NULL != ctx->cb) + ctx->cb (ctx->cb_cls, + _("Failed to receive `HELLO' from peer\n")); + GNUNET_free (ctx); +} +#endif + + /** * Receive the HELLO from one peer, give it to the other * and ask them to connect. * * @param cls "struct ConnectContext" - * @param latency how fast is the connection - * @param peer ID of peer giving us the HELLO * @param message HELLO message of peer */ static void process_hello (void *cls, - struct GNUNET_TIME_Relative latency, - const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message) { struct ConnectContext *ctx = cls; - if (peer == NULL) - { - /* signal error */ - GNUNET_TRANSPORT_disconnect (ctx->d1th); - GNUNET_TRANSPORT_disconnect (ctx->d2th); - if (NULL != ctx->cb) - ctx->cb (ctx->cb_cls, - _("Failed to receive `HELLO' from peer\n")); - GNUNET_free (ctx); - return; - } + /* first of all, stop the notification stuff */ + GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th, + &process_hello, + ctx); #if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' from transport service of `%4s'\n", @@ -1071,9 +1078,10 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, if (NULL != cb) cb (cb_cls, _("Failed to connect to transport service!\n")); return; - } + } + /* FIXME: need to handle timeout: start timeout task + as well here! (use 'timeout_hello_task') */ GNUNET_TRANSPORT_get_hello (ctx->d1th, - timeout, &process_hello, ctx); }