- stats
authorMatthias Wachs <wachs@net.in.tum.de>
Sat, 12 May 2012 12:31:33 +0000 (12:31 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Sat, 12 May 2012 12:31:33 +0000 (12:31 +0000)
src/transport/gnunet-service-transport.c

index 981cd33faca4c04a78ff4491258d1d5d2c778af1..c917a461b65cf0e8313663051160208b38f03689 100644 (file)
@@ -221,8 +221,6 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
   struct GNUNET_TIME_Relative ret;
   struct GNUNET_HELLO_Address address;
   uint16_t type;
-  static unsigned int bytes_total_received;
-  static unsigned int bytes_payload_received;
 
   address.peer = *peer;
   address.address = sender_address;
@@ -234,11 +232,10 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
   type = ntohs (message->type);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received Message with type %u\n", type);
 
-  bytes_total_received += ntohs (message->size);
-  GNUNET_STATISTICS_set (GST_stats,
+  GNUNET_STATISTICS_update (GST_stats,
                         gettext_noop
                         ("# bytes total received"),
-                        bytes_total_received, GNUNET_NO);
+                            ntohs (message->size), GNUNET_NO);
 
   switch (type)
   {
@@ -282,11 +279,10 @@ plugin_env_receive_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
     break;
   default:
     /* should be payload */
-    bytes_payload_received += ntohs (message->size);
-    GNUNET_STATISTICS_set (GST_stats,
-                          gettext_noop
-                          ("# bytes payload received"),
-                          bytes_payload_received, GNUNET_NO);
+    GNUNET_STATISTICS_update (GST_stats,
+                              gettext_noop
+                              ("# bytes payload received"),
+                              -ntohs (message->size), GNUNET_NO);
     ret = process_payload (peer, &address, session, message, ats, ats_count);
     break;
   }