gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r10593 - in gnunet/src: core hostlist


From: gnunet
Subject: [GNUnet-SVN] r10593 - in gnunet/src: core hostlist
Date: Mon, 15 Mar 2010 08:58:30 +0100

Author: grothoff
Date: 2010-03-15 08:58:30 +0100 (Mon, 15 Mar 2010)
New Revision: 10593

Modified:
   gnunet/src/core/Makefile.am
   gnunet/src/core/gnunet-service-core.c
   gnunet/src/hostlist/hostlist-client.c
   gnunet/src/hostlist/hostlist-server.c
Log:
fix

Modified: gnunet/src/core/Makefile.am
===================================================================
--- gnunet/src/core/Makefile.am 2010-03-14 17:02:29 UTC (rev 10592)
+++ gnunet/src/core/Makefile.am 2010-03-15 07:58:30 UTC (rev 10593)
@@ -34,6 +34,7 @@
 gnunet_service_core_LDADD = \
   $(top_builddir)/src/hello/libgnunethello.la \
   $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+  $(top_builddir)/src/statistics/libgnunetstatistics.la \
   $(top_builddir)/src/transport/libgnunettransport.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)

Modified: gnunet/src/core/gnunet-service-core.c
===================================================================
--- gnunet/src/core/gnunet-service-core.c       2010-03-14 17:02:29 UTC (rev 
10592)
+++ gnunet/src/core/gnunet-service-core.c       2010-03-15 07:58:30 UTC (rev 
10593)
@@ -37,6 +37,7 @@
 #include "gnunet_peerinfo_service.h"
 #include "gnunet_protocols.h"
 #include "gnunet_signatures.h"
+#include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
 #include "core.h"
 
@@ -690,6 +691,11 @@
 static struct Neighbour *neighbours;
 
 /**
+ * For creating statistics.
+ */
+static struct GNUNET_STATISTICS_Handle *stats;
+
+/**
  * Sum of all preferences among all neighbours.
  */
 static unsigned long long preference_sum;
@@ -737,6 +743,7 @@
       preference_sum += n->current_preference;
       n = n->next;
     }    
+  GNUNET_STATISTICS_set (stats, gettext_noop ("# total peer preference"), 
preference_sum, GNUNET_NO);
 }
 
 
@@ -1094,8 +1101,10 @@
     GNUNET_SCHEDULER_cancel (sched, n->quota_update_task);
   if (n->dead_clean_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (sched, n->dead_clean_task);
-  if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
-    GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task);
+  if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)    
+      GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task);
+  if (n->status == PEER_STATE_KEY_CONFIRMED)
+    GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), -1, 
GNUNET_NO);
   GNUNET_free_non_null (n->public_key);
   GNUNET_free_non_null (n->pending_ping);
   GNUNET_free_non_null (n->pending_pong);
@@ -1141,6 +1150,7 @@
                                             (const struct
                                              
GNUNET_CRYPTO_AesInitializationVector
                                              *) iv, out));
+  GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes encrypted"), size, 
GNUNET_NO);
 #if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Encrypted %u bytes for `%4s' using key %u\n", size,
@@ -1286,6 +1296,7 @@
     prev->next = n->next;
   GNUNET_assert (neighbour_count > 0);
   neighbour_count--;
+  GNUNET_STATISTICS_set (stats, gettext_noop ("# active neighbours"), 
neighbour_count, GNUNET_NO);
   free_neighbour (n);
 }
 
@@ -1444,6 +1455,7 @@
       GNUNET_break (0);
       return GNUNET_SYSERR;
     }
+  GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes decrypted"), size, 
GNUNET_NO);
 #if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Decrypted %u bytes from `%4s' using key %u\n",
@@ -2050,6 +2062,7 @@
   n->next = neighbours;
   neighbours = n;
   neighbour_count++;
+  GNUNET_STATISTICS_set (stats, gettext_noop ("# active neighbours"), 
neighbour_count, GNUNET_NO);
   n->peer = *pid;
   GNUNET_CRYPTO_aes_create_session_key (&n->encrypt_key);
   now = GNUNET_TIME_absolute_get ();
@@ -2250,6 +2263,7 @@
   if ( (n->is_connected) ||
        (n->th != NULL) )
     return; /* already connected, or at least trying */
+  GNUNET_STATISTICS_update (stats, gettext_noop ("# connection requests 
received"), 1, GNUNET_NO);
 #if DEBUG_CORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Core received `%s' request for `%4s', will try to establish 
connection\n",
@@ -2721,7 +2735,7 @@
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Confirmed key via `%s' message for peer `%4s'\n",
                   "PONG", GNUNET_i2s (&n->peer));
-#endif
+#endif      
       if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_TASK)
         {
           GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task);
@@ -3267,6 +3281,7 @@
           GNUNET_break_op (0);
           return;
         }
+      GNUNET_STATISTICS_update (stats, gettext_noop ("# session keys 
received"), 1, GNUNET_NO);
       handle_set_key (n, (const struct SetKeyMessage *) message);
       break;
     case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
@@ -3290,6 +3305,7 @@
           GNUNET_break_op (0);
           return;
         }
+      GNUNET_STATISTICS_update (stats, gettext_noop ("# ping messages 
received"), 1, GNUNET_NO);
       if ((n->status != PEER_STATE_KEY_RECEIVED) &&
           (n->status != PEER_STATE_KEY_CONFIRMED))
         {
@@ -3311,6 +3327,7 @@
           GNUNET_break_op (0);
           return;
         }
+      GNUNET_STATISTICS_update (stats, gettext_noop ("# pong messages 
received"), 1, GNUNET_NO);
       if ( (n->status != PEER_STATE_KEY_RECEIVED) &&
           (n->status != PEER_STATE_KEY_CONFIRMED) )
         {
@@ -3336,7 +3353,10 @@
       now = GNUNET_TIME_absolute_get ();
       n->last_activity = now;
       if (!up)
-        n->time_established = now;
+       {
+         GNUNET_STATISTICS_update (stats, gettext_noop ("# peers connected"), 
1, GNUNET_NO);
+         n->time_established = now;
+       }
       if (n->keep_alive_task != GNUNET_SCHEDULER_NO_TASK)
        GNUNET_SCHEDULER_cancel (sched, n->keep_alive_task);
       n->keep_alive_task 
@@ -3545,12 +3565,15 @@
       neighbour_count--;
       free_neighbour (n);
     }
+  GNUNET_STATISTICS_set (stats, gettext_noop ("# active neighbours"), 
neighbour_count, GNUNET_NO);
   GNUNET_SERVER_notification_context_destroy (notifier);
   notifier = NULL;
   while (NULL != (c = clients))
     handle_client_disconnect (NULL, c->client_handle);
   if (my_private_key != NULL)
     GNUNET_CRYPTO_rsa_key_free (my_private_key);
+  if (stats != NULL)
+    GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
 }
 
 
@@ -3620,6 +3643,7 @@
                                         &handle_transport_notify_connect,
                                         &handle_transport_notify_disconnect);
   GNUNET_assert (NULL != transport);
+  stats = GNUNET_STATISTICS_create (sched, "core", cfg);
   GNUNET_SCHEDULER_add_delayed (sched,
                                 GNUNET_TIME_UNIT_FOREVER_REL,
                                 &cleaning_task, NULL);

Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c       2010-03-14 17:02:29 UTC (rev 
10592)
+++ gnunet/src/hostlist/hostlist-client.c       2010-03-15 07:58:30 UTC (rev 
10593)
@@ -28,6 +28,7 @@
 #include "hostlist-client.h"
 #include "gnunet_core_service.h"
 #include "gnunet_hello_lib.h"
+#include "gnunet_statistics_service.h"
 #include "gnunet_transport_service.h"
 #include <curl/curl.h>
 
@@ -142,6 +143,10 @@
     {
       return total;  /* ok, no data or bogus data */
     }
+  GNUNET_STATISTICS_update (stats, 
+                           gettext_noop ("# bytes downloaded from hostlist 
servers"), 
+                           (int64_t) total, 
+                           GNUNET_NO);  
   left = total;
   while (left > 0)
     {
@@ -159,6 +164,10 @@
       msize = ntohs(msg->size);
       if (msize < sizeof(struct GNUNET_MessageHeader))
        {        
+         GNUNET_STATISTICS_update (stats, 
+                                   gettext_noop ("# invalid HELLOs downloaded 
from hostlist servers"), 
+                                   1, 
+                                   GNUNET_NO);  
          GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                      _("Invalid `%s' message received from hostlist at 
`%s'\n"),
                      "HELLO",
@@ -175,10 +184,18 @@
                      "Received valid `%s' message from hostlist server.\n",
                      "HELLO");
 #endif
+         GNUNET_STATISTICS_update (stats, 
+                                   gettext_noop ("# valid HELLOs downloaded 
from hostlist servers"), 
+                                   1, 
+                                   GNUNET_NO);  
          GNUNET_TRANSPORT_offer_hello (transport, msg);
        }
       else
        {
+         GNUNET_STATISTICS_update (stats, 
+                                   gettext_noop ("# invalid HELLOs downloaded 
from hostlist servers"), 
+                                   1, 
+                                   GNUNET_NO);  
          GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                      _("Invalid `%s' message received from hostlist at 
`%s'\n"),
                      "HELLO",
@@ -495,7 +512,10 @@
   GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
              _("Bootstrapping using hostlist at `%s'.\n"), 
              current_url);
-
+  GNUNET_STATISTICS_update (stats, 
+                           gettext_noop ("# hostlist downloads initiated"), 
+                           1, 
+                           GNUNET_NO);  
   if (proxy != NULL)
     CURL_EASY_SETOPT (curl, CURLOPT_PROXY, proxy);    
   download_pos = 0;
@@ -660,6 +680,10 @@
                 uint32_t distance)
 {
   connection_count++;
+  GNUNET_STATISTICS_update (stats, 
+                           gettext_noop ("# active connections"), 
+                           1, 
+                           GNUNET_NO);  
 }
 
 
@@ -675,6 +699,10 @@
                    GNUNET_PeerIdentity * peer)
 {
   connection_count--;
+  GNUNET_STATISTICS_update (stats, 
+                           gettext_noop ("# active connections"), 
+                           -1, 
+                           GNUNET_NO);  
 }
 
 
@@ -783,7 +811,6 @@
   proxy = NULL;
   cfg = NULL;
   sched = NULL;
-  stats = NULL;
 }
 
 /* end of hostlist-client.c */

Modified: gnunet/src/hostlist/hostlist-server.c
===================================================================
--- gnunet/src/hostlist/hostlist-server.c       2010-03-14 17:02:29 UTC (rev 
10592)
+++ gnunet/src/hostlist/hostlist-server.c       2010-03-15 07:58:30 UTC (rev 
10593)
@@ -92,7 +92,7 @@
  */
 struct HostSet
 {
-  size_t size;
+  unsigned int size;
 
   char *data;
 };





reply via email to

[Prev in Thread] Current Thread [Next in Thread]