From 7c08695824b0e8526ed6c26e7b29475f4faf8cfd Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 6 May 2010 13:26:11 +0000 Subject: [PATCH] --- src/transport/plugin_transport_http.c | 13 +++++++--- src/transport/test_plugin_transport_http.c | 30 +++++++++++++++++----- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index bff92dd93..f76dc036d 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -268,6 +268,8 @@ http_plugin_send (void *cls, if (ret != CURLE_OK) { /* clean_up (); */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Peer URL is not correct\n"); return 0; } CURL_EASY_SETOPT (curl, @@ -294,6 +296,8 @@ http_plugin_send (void *cls, if (curl_multi == NULL) { GNUNET_break (0); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "curl multi is not correct\n"); /* clean_up (); */ return 0; } @@ -316,6 +320,7 @@ http_plugin_send (void *cls, } + fd_set rs; fd_set ws; fd_set es; @@ -355,10 +360,8 @@ http_plugin_send (void *cls, gws = GNUNET_NETWORK_fdset_create (); GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); -#if DEBUG_HOSTLIST_CLIENT GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling task for hostlist download using cURL\n"); -#endif ti_download = GNUNET_SCHEDULER_add_select (plugin->env->sched, GNUNET_SCHEDULER_PRIORITY_DEFAULT, @@ -374,7 +377,9 @@ http_plugin_send (void *cls, GNUNET_free(peer_url); /* FIXME: */ bytes_sent = msgbuf_size; - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Logging shutdown\n"); + GNUNET_STATISTICS_set(plugin->env->stats,"shutdown",2, GNUNET_NO); return bytes_sent; } @@ -604,7 +609,7 @@ libgnunet_plugin_transport_http_done (void *cls) if ( ti_download != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel(plugin->env->sched, ti_download); - http_task_v4 = GNUNET_SCHEDULER_NO_TASK; + ti_download = GNUNET_SCHEDULER_NO_TASK; } if ( http_task_v4 != GNUNET_SCHEDULER_NO_TASK) diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index f9304be6e..cde888bb8 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c @@ -151,6 +151,7 @@ shutdown_clean () api)); if (my_private_key != NULL) GNUNET_CRYPTO_rsa_key_free (my_private_key); + if (ti_check_stat != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel(sched, ti_check_stat); GNUNET_SCHEDULER_shutdown(sched); @@ -177,9 +178,19 @@ process_stat (void *cls, uint64_t value, int is_persistent) { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("Value: %llums\n"), - (unsigned long long) value); + if (value==1) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown, plugin failed \n"); + fail = GNUNET_YES; + shutdown_clean(); + return; + } + if (value==2) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown, plugin not failed \n"); + shutdown_clean(); + return; + } return GNUNET_OK; } @@ -195,6 +206,8 @@ task_check_stat (void *cls, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "check...%u \n", timeout_count); ti_check_stat = GNUNET_SCHEDULER_NO_TASK; + if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) + return; if ( timeout_count > 3 ) { @@ -203,10 +216,16 @@ task_check_stat (void *cls, } timeout_count++; - if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) - return; + GNUNET_STATISTICS_get (stats, + "http-transport", + gettext_noop("shutdown"), + GNUNET_TIME_UNIT_MINUTES, + NULL, + &process_stat, + NULL); ti_check_stat = GNUNET_SCHEDULER_add_delayed (sched, STAT_INTERVALL, &task_check_stat, NULL); + return; } /** @@ -312,7 +331,6 @@ run (void *cls, /* check statistics */ ti_check_stat = GNUNET_SCHEDULER_add_now(sched, &task_check_stat, NULL); - //GNUNET_STATISTICS_get(stats, "http-transport", ) //ps shutdown_clean (); return; -- 2.25.1