gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32651 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r32651 - gnunet/src/mesh
Date: Fri, 14 Mar 2014 16:49:17 +0100

Author: bartpolot
Date: 2014-03-14 16:49:17 +0100 (Fri, 14 Mar 2014)
New Revision: 32651

Modified:
   gnunet/src/mesh/gnunet-mesh-profiler.c
Log:
- refactor

Modified: gnunet/src/mesh/gnunet-mesh-profiler.c
===================================================================
--- gnunet/src/mesh/gnunet-mesh-profiler.c      2014-03-14 15:49:17 UTC (rev 
32650)
+++ gnunet/src/mesh/gnunet-mesh-profiler.c      2014-03-14 15:49:17 UTC (rev 
32651)
@@ -354,28 +354,16 @@
 /**
  * Transmit ready callback.
  *
- * @param cls Closure (unused).
+ * @param cls Closure (peer for PING, NULL for PONG).
  * @param size Size of the tranmist buffer.
  * @param buf Pointer to the beginning of the buffer.
  *
  * @return Number of bytes written to buf.
  */
 static size_t
-tmt_ping_rdy (void *cls, size_t size, void *buf);
+tmt_rdy (void *cls, size_t size, void *buf);
 
-/**
- * Transmit ready callback.
- *
- * @param cls Closure (unused).
- * @param size Size of the tranmist buffer.
- * @param buf Pointer to the beginning of the buffer.
- *
- * @return Number of bytes written to buf.
- */
-static size_t
-tmt_pong_rdy (void *cls, size_t size, void *buf);
 
-
 /**
  * @brief Send a ping to destination
  *
@@ -396,7 +384,7 @@
 
   GNUNET_MESH_notify_transmit_ready (peer->ch, GNUNET_NO,
                                      GNUNET_TIME_UNIT_FOREVER_REL,
-                                     size_payload, &tmt_ping_rdy, peer);
+                                     size_payload, &tmt_rdy, peer);
 }
 
 /**
@@ -410,19 +398,19 @@
 {
   GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
                                      GNUNET_TIME_UNIT_FOREVER_REL,
-                                     size_payload, &tmt_pong_rdy, NULL);
+                                     size_payload, &tmt_rdy, NULL);
 }
 
 
 /**
  * Transmit ready callback
  *
- * @param cls Closure (unused).
+ * @param cls Closure (peer for PING, NULL for PONG).
  * @param size Size of the buffer we have.
  * @param buf Buffer to copy data to.
  */
-size_t
-tmt_ping_rdy (void *cls, size_t size, void *buf)
+static size_t
+tmt_rdy (void *cls, size_t size, void *buf)
 {
   struct MeshPeer *peer = (struct MeshPeer *) cls;
   struct GNUNET_MessageHeader *msg = buf;
@@ -432,15 +420,20 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy called, filling buffer\n");
   if (size < size_payload || NULL == buf)
   {
-    GNUNET_break (ok >= ok_goal - 2);
+    GNUNET_break (0);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "size %u, buf %p, data_sent %u, data_received %u\n",
                 size, buf, peer->data_sent, peer->data_received);
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
 
     return 0;
   }
   msg->size = htons (size);
+  if (NULL == peer)
+  {
+    msg->type = htons (PONG);
+    return sizeof (*msg);
+  }
+
   msg->type = htons (PING);
   data = (uint32_t *) &msg[1];
   *data = htonl (peer->data_sent);
@@ -464,31 +457,6 @@
 
 
 /**
- * Transmit ready callback
- *
- * @param cls Closure (unused).
- * @param size Size of the buffer we have.
- * @param buf Buffer to copy data to.
- */
-size_t
-tmt_pong_rdy (void *cls, size_t size, void *buf)
-{
-  struct GNUNET_MessageHeader *msg = buf;
-  size_t size_payload = sizeof (struct GNUNET_MessageHeader);
-
-  if (size < size_payload || NULL == buf)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot send PONG\n");
-    return 0;
-  }
-  msg->size = htons (size_payload);
-  msg->type = htons (PONG);
-
-  return size_payload;
-}
-
-
-/**
  * Function is called whenever a PING message is received.
  *
  * @param cls closure (peer #, set from GNUNET_MESH_connect)




reply via email to

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