(no commit message)
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 26 Apr 2010 15:31:07 +0000 (15:31 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 26 Apr 2010 15:31:07 +0000 (15:31 +0000)
src/hostlist/hostlist-client.c
src/hostlist/hostlist-client.h
src/hostlist/hostlist-server.c
src/hostlist/hostlists_adv_peer.file [new file with mode: 0644]
src/hostlist/test_gnunet_daemon_hostlist_learning.c
src/hostlist/test_learning_adv_peer.conf
src/hostlist/test_learning_learn_peer.conf
src/hostlist/test_learning_learn_peer2.conf [new file with mode: 0644]

index 6e61586ae08f561b8bd82b4bc73dba6923a26081..8e78dd809cfa5124e089fc8af4cace1503b21b44 100644 (file)
@@ -252,6 +252,7 @@ static unsigned int stat_hellos_obtained;
  */
 static unsigned int stat_connection_count;
 
+unsigned int downloaded_hellos;
 
 /**
  * Process downloaded bits by calling callback on each HELLO.
@@ -280,6 +281,15 @@ callback_download (void *ptr,
     {
       return total;  /* ok, no data or bogus data */
     }
+
+  if ( downloaded_hellos >= MAX_HELLO_PER_HOSTLISTS )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  _("Maximum number of HELLO Messages per download reached: %u'\n"),
+                  MAX_HELLO_PER_HOSTLISTS );
+    return total;
+
+  }
   GNUNET_STATISTICS_update (stats, 
                            gettext_noop ("# bytes downloaded from hostlist servers"), 
                            (int64_t) total, 
@@ -311,7 +321,9 @@ callback_download (void *ptr,
          GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                      _("Invalid `%s' message received from hostlist at `%s'\n"),
                      "HELLO",
-                     current_url); 
+                     current_url);
+          stat_hellos_obtained++;
+          downloaded_hellos++;
          stat_bogus_url = 1;
          return total;
        }
@@ -332,6 +344,7 @@ callback_download (void *ptr,
                                    1, 
                                    GNUNET_NO);
          stat_hellos_obtained++;
+         downloaded_hellos++;
          GNUNET_TRANSPORT_offer_hello (transport, msg);
        }
       else
@@ -345,6 +358,8 @@ callback_download (void *ptr,
                      "HELLO",
                      current_url);
          stat_bogus_url = GNUNET_YES;
+          stat_hellos_obtained++;
+          downloaded_hellos++;
          return total;
        }
       memmove (download_buffer,
@@ -674,7 +689,6 @@ clean_up ()
     hostlist_to_test = NULL;
   }
 
-
   if (multi != NULL)
     {
       mret = curl_multi_remove_handle (multi, curl);
@@ -700,7 +714,7 @@ clean_up ()
     }  
   GNUNET_free_non_null (current_url);
   current_url = NULL;
-
+  downloaded_hellos = 0;
   stat_download_in_progress = GNUNET_NO;
 }
 
@@ -792,7 +806,7 @@ static void
 task_download (void *cls,
             const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  unsigned int counter;
+
   int running;
   struct CURLMsg *msg;
   CURLMcode mret;
@@ -823,7 +837,6 @@ task_download (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Ready for processing hostlist client request\n");
 #endif
-  counter = 0;
   do 
     {
       running = 0;
@@ -834,7 +847,6 @@ task_download (void *cls,
            {
 
              msg = curl_multi_info_read (multi, &running);
-             counter ++;
              GNUNET_break (msg != NULL);
              if (msg == NULL)
                break;
@@ -855,6 +867,8 @@ task_download (void *cls,
                    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                                _("Download of hostlist `%s' completed.\n"),
                                current_url);
+                    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                                      _("HELLOs recieved: %u \n"),downloaded_hellos);
                    stat_download_successful = GNUNET_YES;
                    update_hostlist();
                    if (GNUNET_YES == stat_testing_hostlist)
@@ -918,6 +932,7 @@ download_hostlist ()
   stat_download_in_progress = GNUNET_YES;
   stat_download_successful = GNUNET_NO;
   stat_hellos_obtained = 0;
+  downloaded_hellos = 0;
 
   GNUNET_STATISTICS_update (stats, 
                            gettext_noop ("# hostlist downloads initiated"), 
index 745187f7c3ee21d7c3c4df9774521b7258bafcfd..5b00360988f81dc8045ad89105a627e2e305e85a 100644 (file)
@@ -33,7 +33,7 @@
 #include "gnunet_time_lib.h"
 
 #define MAX_NUMBER_HOSTLISTS 30
-#define MAX_HELLO_PER_HOSTLISTS 0
+#define MAX_HELLO_PER_HOSTLISTS 50
 #define SAVING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30)
 #define TESTING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
 #define WAITING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
index 37fb4a4e1c185044224c8b574199ff1c53d6b2de..3a2a730d1d5bda768f36443ce4ef8228927ee917 100644 (file)
@@ -32,7 +32,7 @@
 #include "gnunet-daemon-hostlist.h"
 #include "gnunet_resolver_service.h"
 
-#define DEBUG_HOSTLIST_SERVER GNUNET_NO
+#define DEBUG_HOSTLIST_SERVER GNUNET_YES
 
 /**
  * How often should we recalculate our response to hostlist requests?
@@ -282,7 +282,6 @@ update_response (void *cls,
                 const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct HostSet *results;
-
   response_task = GNUNET_SCHEDULER_NO_TASK;
   results = GNUNET_malloc(sizeof(struct HostSet));
   GNUNET_assert (peerinfo != NULL);
@@ -438,6 +437,11 @@ connect_handler (void *cls,
 {
   size_t size;
 
+  /* FIXME: Change this way to update the list to peerinfo_notify */
+  response_task = GNUNET_SCHEDULER_add_now (sched,
+                                            &update_response,
+                                            NULL);
+
   if ( !advertising )
     return;
   if (hostlist_uri == NULL)
@@ -455,8 +459,8 @@ connect_handler (void *cls,
       return;
     }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Asked core to transmit advertisement message with a size of %u bytes\n", 
-             size);
+              "Asked core to transmit advertisement message with a size of %u bytes to peer `%s'\n",
+             size,GNUNET_i2s(peer));
   if (NULL == GNUNET_CORE_notify_transmit_ready (core,
                                                 0,
                                                 GNUNET_ADV_TIMEOUT,
diff --git a/src/hostlist/hostlists_adv_peer.file b/src/hostlist/hostlists_adv_peer.file
new file mode 100644 (file)
index 0000000..e69de29
index b529eb86d1c5edd49be40028874edb21705c1a1e..8f457fa1ebdb81ac541e2d8320e84d4938a49dbe 100644 (file)
@@ -71,6 +71,8 @@ static struct PeerContext adv_peer;
 
 static struct PeerContext learn_peer;
 
+static struct PeerContext learn_peer2;
+
 
 static void
 waitpid_task (void *cls,
@@ -137,6 +139,11 @@ static void shutdown_testcase()
     GNUNET_TRANSPORT_disconnect (learn_peer.th);
     learn_peer.th = NULL;
   }
+  if (learn_peer2.th != NULL)
+  {
+    GNUNET_TRANSPORT_disconnect (learn_peer2.th);
+    learn_peer2.th = NULL;
+  }
   if (adv_peer.core != NULL)
   {
     GNUNET_CORE_disconnect (adv_peer.core);
@@ -147,11 +154,19 @@ static void shutdown_testcase()
     GNUNET_CORE_disconnect (learn_peer.core);
     learn_peer.core = NULL;
   }
+  if (learn_peer2.core != NULL)
+  {
+    GNUNET_CORE_disconnect (learn_peer2.core);
+    learn_peer2.core = NULL;
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Asking ARM to stop core services\n");
   learn_peer.arm = GNUNET_ARM_connect (learn_peer.cfg, sched, NULL);
   GNUNET_ARM_stop_service (learn_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS,
                            &stop_cb, &learn_peer);
+  learn_peer2.arm = GNUNET_ARM_connect (learn_peer2.cfg, sched, NULL);
+  GNUNET_ARM_stop_service (learn_peer2.arm, "core", GNUNET_TIME_UNIT_SECONDS,
+                           &stop_cb, &learn_peer2);
   adv_peer.arm = GNUNET_ARM_connect (adv_peer.cfg, sched, NULL);
   GNUNET_ARM_stop_service (adv_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS,
                            &stop_cb, &adv_peer);
@@ -415,6 +430,8 @@ run (void *cls,
 
   setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf");
   setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf");
+  setup_learn_peer (&learn_peer2, "test_learning_learn_peer2.conf");
+
 }
 
 
index 9af51e8f2716754e896fd406878ce33628ebda56..723111d75da731a1a788533af0560986d6ea56c0 100644 (file)
@@ -34,10 +34,11 @@ PORT = 22970
 WEAKRANDOM = YES
 
 [hostlist]
-HTTPPORT = 12981s
-SERVERS = http://localhost:12980/
-OPTIONS = -b -p -a
-DEBUG = NO
+HTTPPORT = 12981
+SERVERS = http://localhost:12981/
+OPTIONS = -p -a -b -e
+#OPTIONS = -b -p -a
+DEBUG = YES
 HOSTLISTFILE = hostlists_adv_peer.file
 #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
 
index 4bdb039e7c6eb77bacbc35d332042cb8c765004a..d7f512e3088777b1e2a8f9d6b2f8badc6cbaf9da 100644 (file)
@@ -35,8 +35,9 @@ WEAKRANDOM = YES
 [hostlist]
 HTTPPORT = 12980
 SERVERS = http://localhost:12981/
-OPTIONS = -b -p -e
-#DEBUG = YES
+OPTIONS = -b -e
+#OPTIONS = -b -p
+DEBUG = YES
 HOSTLISTFILE = hostlists_learn_peer.file
 #BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
 
diff --git a/src/hostlist/test_learning_learn_peer2.conf b/src/hostlist/test_learning_learn_peer2.conf
new file mode 100644 (file)
index 0000000..3279fbf
--- /dev/null
@@ -0,0 +1,47 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunetd-hostlist-peer-3/
+DEFAULTCONFIG = test_learning_learn_peer2.conf
+[resolver]
+PORT = 32964
+
+[transport]
+PORT = 32965
+PLUGINS = tcp
+#DEBUG = YES
+
+[arm]
+PORT = 32966
+DEFAULTSERVICES = resolver transport core statistics topology hostlist
+#GLOBAL_PREFIX = xterm -e gdb -x cmd --args 
+#DEBUG=NO
+
+[statistics]
+PORT = 32967
+
+[transport-tcp]
+PORT = 32968
+
+[peerinfo]
+PORT = 32969
+
+[core]
+PORT = 32970
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
+
+[testing]
+WEAKRANDOM = YES
+
+[hostlist]
+HTTPPORT = 32980
+SERVERS = http://localhost:12981/
+OPTIONS = -b -e
+#OPTIONS = -b -p
+DEBUG = YES
+HOSTLISTFILE = hostlists_learn_peer2.file
+#BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
+
+
+[topology]
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck