-remove GNUNET_MQ_impl_send_commit, make it part of send_continue, to ensure calling...
authorChristian Grothoff <christian@grothoff.org>
Sat, 16 Nov 2013 17:41:13 +0000 (17:41 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sat, 16 Nov 2013 17:41:13 +0000 (17:41 +0000)
src/conversation/gnunet-conversation.c
src/core/core_api.c
src/include/gnunet_mq_lib.h
src/mesh/mesh_api.c
src/util/mq.c

index 45ecdac916beafc31cb7ea9150d74946303129e7..05b3044b6f07e4d883fe0a24b3ec49109dd6a189 100644 (file)
@@ -787,7 +787,7 @@ do_resume (const char *args)
   case PS_ERROR:
     FPRINTF (stderr,
              "%s",
-             _("There is no call that could be suspended right now.\n"));
+             _("There is no call that could be resumed right now.\n"));
     return;
   case PS_LISTEN:
     /* expected state, do resume logic */
@@ -1054,6 +1054,8 @@ handle_command (void *cls,
   ptr = &message[strlen (commands[i].command)];
   while (isspace ((int) *ptr))
     ptr++;
+  if ('\0' == ptr)
+    ptr = NULL;
   commands[i].Action (ptr);
 }
 
index 34c235bbd16ce7b87ccfa6a3ff6d00a41ded57be..f07d1ca47a5c9957fe0ef10a1d210499547a7f06 100644 (file)
@@ -1424,7 +1424,6 @@ core_mq_ntr (void *cls, size_t size,
     return 0;
   }
   memcpy (buf, mh, msg_size);
-  GNUNET_MQ_impl_send_commit (mq);
   GNUNET_MQ_impl_send_continue (mq);
   return msg_size;
 }
@@ -1448,7 +1447,7 @@ core_mq_send (struct GNUNET_MQ_Handle *mq,
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "core-mq", "Sending queued message (size %u)\n",
              ntohs (msg->size));
   mqs->th = GNUNET_CORE_notify_transmit_ready (mqs->core, GNUNET_YES, 0,
-                                               GNUNET_TIME_UNIT_FOREVER_REL, 
+                                               GNUNET_TIME_UNIT_FOREVER_REL,
                                                &mqs->target,
                                                ntohs (msg->size), core_mq_ntr, mq);
 }
@@ -1459,7 +1458,7 @@ core_mq_send (struct GNUNET_MQ_Handle *mq,
  * destruction of a message queue.
  * Implementations must not free @a mq, but should
  * take care of @a impl_state.
- * 
+ *
  * @param mq the message queue to destroy
  * @param impl_state state of the implementation
  */
@@ -1478,7 +1477,7 @@ core_mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state)
 
 /**
  * Implementation function that cancels the currently sent message.
- * 
+ *
  * @param mq message queue
  * @param impl_state state specific to the implementation
  */
index 651c698e164519af09fe95a37d003e7523ab85e1..26330f3ee62b835d883507829529d450c2d1ee1c 100644 (file)
@@ -389,9 +389,9 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send,
 
 
 /**
- * Replace the handlers of a message queue with new handlers.
- * Takes effect immediately, even for messages that already have been received, but for
- * with the handler has not been called.
+ * Replace the handlers of a message queue with new handlers.  Takes
+ * effect immediately, even for messages that already have been
+ * received, but for with the handler has not been called.
  *
  * If the message queue does not support receiving messages,
  * this function has no effect.
@@ -506,16 +506,6 @@ void *
 GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq);
 
 
-/**
- * Mark the current message as irrevocably sent, but do not
- * proceed with sending the next message.
- * Will call the appropriate GNUNET_MQ_NotifyCallback, if any.
- *
- * @param mq message queue
- */
-void
-GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq);
-
 /** @} */ /* end of group mq */
 
 #endif
index b35a4dc14ebfd39699c466cd93b5b4d5a27542a5..9b18df8dda99670c55f17a236d8539a8227e05ea 100644 (file)
@@ -1710,7 +1710,6 @@ mesh_mq_ntr (void *cls, size_t size,
   GNUNET_assert (msize <= size);
   memcpy (buf, msg, msize);
   GNUNET_MQ_impl_send_continue (mq);
-  GNUNET_MQ_impl_send_commit (mq);
   return msize;
 }
 
index d8659ec40ced01c1faab179b7c9b1f7b46e11b47..3cf5da496bb01c8ede62c8beb7fa6255849b51b0 100644 (file)
@@ -120,12 +120,6 @@ struct GNUNET_MQ_Handle
    */
   struct GNUNET_MQ_Envelope *current_envelope;
 
-  /**
-   * Has the current envelope been commited?
-   * Either GNUNET_YES or GNUNET_NO.
-   */
-  int commited;
-
   /**
    * Map of associations, lazily allocated
    */
@@ -265,25 +259,27 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
 void
 GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq)
 {
+  struct GNUNET_MQ_Envelope *current_envelope;
+
   /* call is only valid if we're actually currently sending
    * a message */
-  GNUNET_assert (NULL != mq);
-  GNUNET_assert (NULL != mq->current_envelope);
-  GNUNET_assert (GNUNET_YES == mq->commited);
-  mq->commited = GNUNET_NO;
-  GNUNET_free (mq->current_envelope);
+  current_envelope = mq->current_envelope;
+  GNUNET_assert (NULL != current_envelope);
   if (NULL == mq->envelope_head)
   {
     mq->current_envelope = NULL;
-    return;
   }
-
-  GNUNET_assert (NULL != mq->envelope_tail);
-  GNUNET_assert (NULL != mq->envelope_head);
-  mq->current_envelope = mq->envelope_head;
-  GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail,
-                               mq->current_envelope);
-  mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state);
+  else
+  {
+    mq->current_envelope = mq->envelope_head;
+    GNUNET_CONTAINER_DLL_remove (mq->envelope_head,
+                                 mq->envelope_tail,
+                                 mq->current_envelope);
+    mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state);
+  }
+  if (NULL != current_envelope->sent_cb)
+    current_envelope->sent_cb (current_envelope->sent_cls);
+  GNUNET_free (current_envelope);
 }
 
 
@@ -362,25 +358,6 @@ GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq)
 }
 
 
-
-/**
- * Mark the current message as irrevocably sent, but do not
- * proceed with sending the next message.
- * Will call the appropriate GNUNET_MQ_NotifyCallback, if any.
- *
- * @param mq message queue
- */
-void
-GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq)
-{
-  GNUNET_assert (NULL != mq->current_envelope);
-  GNUNET_assert (GNUNET_NO == mq->commited);
-  mq->commited = GNUNET_YES;
-  if (NULL != mq->current_envelope->sent_cb)
-    mq->current_envelope->sent_cb (mq->current_envelope->sent_cls);
-}
-
-
 struct GNUNET_MQ_Envelope *
 GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type)
 {
@@ -479,9 +456,6 @@ server_client_send_impl (struct GNUNET_MQ_Handle *mq,
 
   GNUNET_assert (NULL != mq);
   GNUNET_assert (NULL != state);
-
-  GNUNET_MQ_impl_send_commit (mq);
-
   state->th =
       GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size),
                                            GNUNET_TIME_UNIT_FOREVER_REL,
@@ -596,9 +570,6 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq,
 
   GNUNET_assert (NULL != state);
   GNUNET_assert (NULL == state->th);
-
-  GNUNET_MQ_impl_send_commit (mq);
-
   state->th =
       GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size),
                                            GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO,