eliminate DHT PUT OK message by using MQ feature of calling continuation when transmi...
[oweals/gnunet.git] / src / util / mq.c
index 33bbaa6ad42531e5eea69cd4ca19f646ace774cf..dbcce704dca500676974fd588fb435258d240216 100644 (file)
@@ -358,10 +358,10 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
   GNUNET_assert (NULL == mq->envelope_head);
   mq->current_envelope = ev;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "mq: sending message of type %u, queue empty (MQ: %p)\n",
-              ntohs(ev->mh->type),
-              mq);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "sending message of type %u, queue empty (MQ: %p)\n",
+       ntohs(ev->mh->type),
+       mq);
 
   mq->send_impl (mq,
                 ev->mh,
@@ -459,9 +459,9 @@ impl_send_continue (void *cls)
                               mq->envelope_tail,
                               mq->current_envelope);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "mq: sending message of type %u from queue\n",
-              ntohs(mq->current_envelope->mh->type));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "sending message of type %u from queue\n",
+       ntohs(mq->current_envelope->mh->type));
 
   mq->send_impl (mq,
                 mq->current_envelope->mh,
@@ -578,11 +578,9 @@ void
 GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq,
                                 void *handlers_cls)
 {
-  unsigned int i;
-
   if (NULL == mq->handlers)
     return;
-  for (i=0;NULL != mq->handlers[i].cb; i++)
+  for (unsigned int i=0;NULL != mq->handlers[i].cb; i++)
     mq->handlers[i].cls = handlers_cls;
 }
 
@@ -782,7 +780,9 @@ GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev,
                        GNUNET_SCHEDULER_TaskCallback cb,
                        void *cb_cls)
 {
-  GNUNET_assert (NULL == ev->sent_cb);
+  /* allow setting *OR* clearing callback */
+  GNUNET_assert ( (NULL == ev->sent_cb) ||
+                  (NULL == cb) );
   ev->sent_cb = cb;
   ev->sent_cls = cb_cls;
 }
@@ -851,9 +851,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
                                 ev);
     GNUNET_assert (0 < mq->queue_length);
     mq->queue_length--;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "MQ destroy drops message of type %u\n",
-                ntohs (ev->mh->type));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "MQ destroy drops message of type %u\n",
+         ntohs (ev->mh->type));
     GNUNET_MQ_discard (ev);
   }
   if (NULL != mq->current_envelope)
@@ -861,9 +861,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
     /* we can only discard envelopes that
      * are not queued! */
     mq->current_envelope->parent_queue = NULL;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "MQ destroy drops current message of type %u\n",
-                ntohs (mq->current_envelope->mh->type));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "MQ destroy drops current message of type %u\n",
+         ntohs (mq->current_envelope->mh->type));
     GNUNET_MQ_discard (mq->current_envelope);
     mq->current_envelope = NULL;
     GNUNET_assert (0 < mq->queue_length);
@@ -946,9 +946,9 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev)
                                    mq->envelope_tail,
                                    mq->current_envelope);
 
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "mq: sending canceled message of type %u queue\n",
-                  ntohs(ev->mh->type));
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "sending canceled message of type %u queue\n",
+           ntohs(ev->mh->type));
 
       mq->send_impl (mq,
                     mq->current_envelope->mh,