(no commit message)
authorMatthias Wachs <wachs@net.in.tum.de>
Thu, 6 May 2010 13:26:11 +0000 (13:26 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Thu, 6 May 2010 13:26:11 +0000 (13:26 +0000)
src/transport/plugin_transport_http.c
src/transport/test_plugin_transport_http.c

index bff92dd936a867ec72257ae0db64fe6df016580a..f76dc036d11dab613ba0c5c63d8854fd73fc2d13 100644 (file)
@@ -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)
index f9304be6e92bedc16682a11e09af2885b59feacc..cde888bb8a30bac84c339d2d7a04313060606516 100644 (file)
@@ -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;