- some stats
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 27 Apr 2012 09:58:39 +0000 (09:58 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 27 Apr 2012 09:58:39 +0000 (09:58 +0000)
src/transport/plugin_transport_unix.c

index c01304b3f975505d3f322236c94032bf737a1ea9..46dee9ce38f35e7399ab28954bd7b3d43eb62038 100644 (file)
@@ -242,6 +242,8 @@ struct Plugin
    * ATS network
    */
   struct GNUNET_ATS_Information ats_network;
+
+  unsigned int bytes_in_queue;
 };
 
 
@@ -632,6 +634,7 @@ unix_plugin_send (void *cls,
           sizeof (struct GNUNET_PeerIdentity));
   memcpy (&message[1], msgbuf, msgbuf_size);
 
+
   wrapper = GNUNET_malloc (sizeof (struct UNIXMessageWrapper));
   wrapper->msg = message;
   wrapper->msgsize = ssize;
@@ -643,6 +646,10 @@ unix_plugin_send (void *cls,
 
   GNUNET_CONTAINER_DLL_insert(plugin->msg_head, plugin->msg_tail, wrapper);
 
+  plugin->bytes_in_queue += ssize;
+  GNUNET_STATISTICS_set (plugin->env->stats,"# UNIX bytes in send queue",
+      plugin->bytes_in_queue, GNUNET_NO);
+
 #if DEBUG_UNIX
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", ssize,
               (char *) session->addr);
@@ -788,6 +795,12 @@ unix_plugin_select_write (struct Plugin * plugin)
   if (sent > 0)
   {
     GNUNET_CONTAINER_DLL_remove(plugin->msg_head, plugin->msg_tail, msgw);
+
+    GNUNET_assert (plugin->bytes_in_queue > msgw->msgsize);
+    plugin->bytes_in_queue -= msgw->msgsize;
+    GNUNET_STATISTICS_set (plugin->env->stats,"# UNIX bytes in send queue",
+        plugin->bytes_in_queue, GNUNET_NO);
+
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
     return;
@@ -797,6 +810,12 @@ unix_plugin_select_write (struct Plugin * plugin)
   if (sent == -1)
   {
     GNUNET_CONTAINER_DLL_remove(plugin->msg_head, plugin->msg_tail, msgw);
+
+    GNUNET_assert (plugin->bytes_in_queue > msgw->msgsize);
+    plugin->bytes_in_queue -= msgw->msgsize;
+    GNUNET_STATISTICS_set (plugin->env->stats,"# UNIX bytes in send queue",
+        plugin->bytes_in_queue, GNUNET_NO);
+
     GNUNET_free (msgw->msg);
     GNUNET_free (msgw);
     return;
@@ -1079,7 +1098,7 @@ libgnunet_plugin_transport_unix_init (void *cls)
     api->cls = NULL;
     api->address_pretty_printer = &unix_plugin_address_pretty_printer;
     api->address_to_string = &unix_address_to_string;
-    api->string_to_address = NULL; // FIXME!
+    api->string_to_address = &unix_string_to_address;
     return api;
   }
   GNUNET_assert( NULL != env->stats);