LRN's patch argument order
[oweals/gnunet.git] / src / util / server_nc.c
index f8e300029298a8aa1c94fa64600b1ac6f6534583..a36fa0c505a21d15881e56de2dd4e7929b01aabd 100644 (file)
@@ -21,7 +21,7 @@
 /**
  * @file util/server_nc.c
  * @brief convenience functions for transmission of
- *        a notification stream 
+ *        a notification stream
  * @author Christian Grothoff
  */
 
 #include "gnunet_server_lib.h"
 #include "gnunet_time_lib.h"
 
+#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
 
-#define DEBUG_SERVER_NC GNUNET_NO
+
+#define DEBUG_SERVER_NC GNUNET_EXTRA_LOGGING
 
 /**
  * Entry in list of messages pending to be transmitted.
@@ -78,7 +80,7 @@ struct ClientList
   struct ClientList *next;
 
   /**
-   * Overall context this client belongs to. 
+   * Overall context this client belongs to.
    */
   struct GNUNET_SERVER_NotificationContext *nc;
 
@@ -170,9 +172,9 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
   if (pos == NULL)
     return;
 #if DEBUG_SERVER_NC
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Client disconnected, cleaning up %u messages in NC queue\n",
-              pos->num_pending);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Client disconnected, cleaning up %u messages in NC queue\n",
+       pos->num_pending);
 #endif
   if (prev == NULL)
     nc->clients = pos->next;
@@ -293,8 +295,8 @@ transmit_message (void *cls, size_t size, void *buf)
   {
     /* 'cl' should be freed via disconnect notification shortly */
 #if DEBUG_SERVER_NC
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Failed to transmit message from NC queue to client\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Failed to transmit message from NC queue to client\n");
 #endif
     return 0;
   }
@@ -306,9 +308,9 @@ transmit_message (void *cls, size_t size, void *buf)
       break;
     GNUNET_CONTAINER_DLL_remove (cl->pending_head, cl->pending_tail, pml);
 #if DEBUG_SERVER_NC
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Copying message of type %u and size %u from pending queue to transmission buffer\n",
-                ntohs (pml->msg->type), msize);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Copying message of type %u and size %u from pending queue to transmission buffer\n",
+         ntohs (pml->msg->type), msize);
 #endif
     memcpy (&cbuf[ret], pml->msg, msize);
     ret += msize;
@@ -319,14 +321,14 @@ transmit_message (void *cls, size_t size, void *buf)
   if (pml != NULL)
   {
 #if DEBUG_SERVER_NC
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Have %u messages left in NC queue, will try transmission again\n",
-                cl->num_pending);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Have %u messages left in NC queue, will try transmission again\n",
+         cl->num_pending);
 #endif
-    cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
-                                                  ntohs (pml->msg->size),
-                                                  GNUNET_TIME_UNIT_FOREVER_REL,
-                                                  &transmit_message, cl);
+    cl->th =
+        GNUNET_SERVER_notify_transmit_ready (cl->client, ntohs (pml->msg->size),
+                                             GNUNET_TIME_UNIT_FOREVER_REL,
+                                             &transmit_message, cl);
   }
   else
     GNUNET_assert (cl->num_pending == 0);
@@ -344,18 +346,17 @@ transmit_message (void *cls, size_t size, void *buf)
  */
 static void
 do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
-            struct ClientList *client,
-            const struct GNUNET_MessageHeader *msg, int can_drop)
+            struct ClientList *client, const struct GNUNET_MessageHeader *msg,
+            int can_drop)
 {
   struct PendingMessageList *pml;
   uint16_t size;
 
   if ((client->num_pending > nc->queue_length) && (GNUNET_YES == can_drop))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Dropping message of type %u and size %u due to full queue (%u entries)\n",
-                ntohs (msg->type),
-                ntohs (msg->size), (unsigned int) nc->queue_length);
+    LOG (GNUNET_ERROR_TYPE_INFO,
+         "Dropping message of type %u and size %u due to full queue (%u entries)\n",
+         ntohs (msg->type), ntohs (msg->size), (unsigned int) nc->queue_length);
     return;                     /* drop! */
   }
   if (client->num_pending > nc->queue_length)
@@ -369,23 +370,21 @@ do_unicast (struct GNUNET_SERVER_NotificationContext *nc,
   pml->msg = (const struct GNUNET_MessageHeader *) &pml[1];
   pml->can_drop = can_drop;
 #if DEBUG_SERVER_NC
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding message of type %u and size %u to pending queue (which has %u entries)\n",
-              ntohs (msg->type),
-              ntohs (msg->size), (unsigned int) nc->queue_length);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Adding message of type %u and size %u to pending queue (which has %u entries)\n",
+       ntohs (msg->type), ntohs (msg->size), (unsigned int) nc->queue_length);
 #endif
   memcpy (&pml[1], msg, size);
   /* append */
-  GNUNET_CONTAINER_DLL_insert_tail (client->pending_head,
-                                    client->pending_tail, pml);
+  GNUNET_CONTAINER_DLL_insert_tail (client->pending_head, client->pending_tail,
+                                    pml);
   if (client->th == NULL)
-    client->th = GNUNET_SERVER_notify_transmit_ready (client->client,
-                                                      ntohs
-                                                      (client->pending_head->
-                                                       msg->size),
-                                                      GNUNET_TIME_UNIT_FOREVER_REL,
-                                                      &transmit_message,
-                                                      client);
+    client->th =
+        GNUNET_SERVER_notify_transmit_ready (client->client,
+                                             ntohs (client->pending_head->
+                                                    msg->size),
+                                             GNUNET_TIME_UNIT_FOREVER_REL,
+                                             &transmit_message, client);
 }