From: Christian Grothoff Date: Thu, 16 Jul 2009 21:49:43 +0000 (+0000) Subject: bugfixes X-Git-Tag: initial-import-from-subversion-38251~23681 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=898876b6f5ab1fe8c5a4de26be4e162d5bb0f6d5;p=oweals%2Fgnunet.git bugfixes --- diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index ad4aec8ca..83f54c0b9 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -1878,10 +1878,11 @@ disconnect_neighbour (struct NeighbourList *n) { n->plugins = rpos->next; GNUNET_assert (rpos->neighbour == n); - rpos->plugin->api->cancel (rpos->plugin->api->cls, - rpos->plugin_handle, - rpos, - &n->id); + if (GNUNET_YES == rpos->connected) + rpos->plugin->api->cancel (rpos->plugin->api->cls, + rpos->plugin_handle, + rpos, + &n->id); GNUNET_free (rpos); } @@ -1892,7 +1893,9 @@ disconnect_neighbour (struct NeighbourList *n) GNUNET_assert (mq->neighbour == n); GNUNET_free (mq); } - + if (n->timeout_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) + GNUNET_SCHEDULER_cancel (sched, + n->timeout_task); /* finally, free n itself */ GNUNET_free (n); } @@ -2054,13 +2057,13 @@ plugin_env_receive (void *cls, GNUNET_i2s(&n->id)); #endif /* TODO: call stats */ - disconnect_neighbour (n); if ((service_context != NULL) && (service_context->plugin_handle == plugin_context)) { service_context->connected = GNUNET_NO; service_context->plugin_handle = NULL; } + disconnect_neighbour (n); return NULL; } #if DEBUG_TRANSPORT @@ -2628,6 +2631,7 @@ unload_plugins (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) } if (my_private_key != NULL) GNUNET_CRYPTO_rsa_key_free (my_private_key); + GNUNET_free_non_null (our_hello); } @@ -2642,10 +2646,10 @@ int main (int argc, char *const *argv) { return (GNUNET_OK == - GNUNET_SERVICE_run (argc, - argv, - "transport", - &run, NULL, &unload_plugins, NULL)) ? 0 : 1; + GNUNET_SERVICE_run (argc, + argv, + "transport", + &run, NULL, &unload_plugins, NULL)) ? 0 : 1; } /* end of gnunet-service-transport.c */ diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index b5b4547cc..11b9f0709 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -415,8 +415,9 @@ find_session_by_target (struct Plugin *plugin, ret = plugin->sessions; while ((ret != NULL) && - (0 != memcmp (target, - &ret->target, sizeof (struct GNUNET_PeerIdentity)))) + ( (GNUNET_SYSERR == ret->expecting_welcome) || + (0 != memcmp (target, + &ret->target, sizeof (struct GNUNET_PeerIdentity))))) ret = ret->next; return ret; } @@ -834,6 +835,11 @@ disconnect_session (struct Session *session) GNUNET_TIME_UNIT_ZERO, &session->target, NULL); } + if (session->client != NULL) + { + GNUNET_SERVER_client_drop (session->client); + session->client = NULL; + } GNUNET_free_non_null (session->connect_addr); GNUNET_free (session); } @@ -2073,7 +2079,10 @@ libgnunet_plugin_transport_tcp_done (void *cls) { struct GNUNET_TRANSPORT_PluginFunctions *api = cls; struct Plugin *plugin = api->cls; + struct Session *session; + while (NULL != (session = plugin->sessions)) + disconnect_session (session); GNUNET_SERVICE_stop (plugin->service); GNUNET_free (plugin->handlers); GNUNET_free (plugin); diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c index d475de859..dab244e45 100644 --- a/src/transport/transport_api.c +++ b/src/transport/transport_api.c @@ -378,7 +378,7 @@ transport_notify_ready (void *cls, size_t size, void *buf) if (buf == NULL) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Could not transmit to transport service, cancelling pending requests\n"); #endif th = h->connect_ready_head; @@ -785,6 +785,27 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct HelloWaitList *pos; struct HelloWaitList *prev; + hwl->task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; + if (GNUNET_TIME_absolute_get_remaining (hwl->timeout).value > 0) + { +#if DEBUG_TRANSPORT + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("First attempt to obtain `%s' from transport service failed, will try again for %llums.\n"), + "HELLO", + GNUNET_TIME_absolute_get_remaining (hwl->timeout).value); +#endif + hwl->task = GNUNET_SCHEDULER_add_delayed (hwl->handle->sched, + GNUNET_YES, + GNUNET_SCHEDULER_PRIORITY_KEEP, + GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, + GNUNET_TIME_absolute_get_remaining (hwl->timeout), + &hello_wait_timeout, hwl); + return; + } + /* signal timeout */ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + _("Timeout trying to obtain `%s' from transport service.\n"), + "HELLO"); prev = NULL; pos = hwl->handle->hwl_head; while (pos != hwl) @@ -797,10 +818,6 @@ hello_wait_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) hwl->handle->hwl_head = hwl->next; else prev->next = hwl->next; - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Timeout trying to obtain `%s' from transport service.\n"), - "HELLO"); - /* signal timeout */ if (hwl->rec != NULL) hwl->rec (hwl->rec_cls, GNUNET_TIME_UNIT_ZERO, NULL, NULL); GNUNET_free (hwl); @@ -932,7 +949,7 @@ send_start (void *cls, size_t size, void *buf) if (buf == NULL) { #if DEBUG_TRANSPORT - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Timeout while trying to transmit `%s' request.\n", "START"); #endif @@ -1152,7 +1169,8 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) schedule_control_transmit (h, sizeof (struct GNUNET_MessageHeader), GNUNET_YES, - GNUNET_TIME_UNIT_FOREVER_REL, &send_start, NULL); + GNUNET_TIME_UNIT_FOREVER_REL, + &send_start, NULL); GNUNET_CLIENT_receive (h->client, &demultiplexer, h, GNUNET_TIME_UNIT_FOREVER_REL); }