diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-16 17:41:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-16 17:41:13 +0000 |
commit | ba0bf2a585c2b59890d8f67074b74725430e86e8 (patch) | |
tree | d4f98f90560b63b632b686a5a6cb6a03c52c6d8a | |
parent | e6fdcba7a3f54eefde196ccbc606acd62d30fb0f (diff) | |
download | gnunet-ba0bf2a585c2b59890d8f67074b74725430e86e8.tar.gz gnunet-ba0bf2a585c2b59890d8f67074b74725430e86e8.zip |
-remove GNUNET_MQ_impl_send_commit, make it part of send_continue, to ensure calling the continuation _last_
-rw-r--r-- | src/conversation/gnunet-conversation.c | 4 | ||||
-rw-r--r-- | src/core/core_api.c | 7 | ||||
-rw-r--r-- | src/include/gnunet_mq_lib.h | 16 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 1 | ||||
-rw-r--r-- | src/util/mq.c | 59 |
5 files changed, 24 insertions, 63 deletions
diff --git a/src/conversation/gnunet-conversation.c b/src/conversation/gnunet-conversation.c index 45ecdac91..05b3044b6 100644 --- a/src/conversation/gnunet-conversation.c +++ b/src/conversation/gnunet-conversation.c | |||
@@ -787,7 +787,7 @@ do_resume (const char *args) | |||
787 | case PS_ERROR: | 787 | case PS_ERROR: |
788 | FPRINTF (stderr, | 788 | FPRINTF (stderr, |
789 | "%s", | 789 | "%s", |
790 | _("There is no call that could be suspended right now.\n")); | 790 | _("There is no call that could be resumed right now.\n")); |
791 | return; | 791 | return; |
792 | case PS_LISTEN: | 792 | case PS_LISTEN: |
793 | /* expected state, do resume logic */ | 793 | /* expected state, do resume logic */ |
@@ -1054,6 +1054,8 @@ handle_command (void *cls, | |||
1054 | ptr = &message[strlen (commands[i].command)]; | 1054 | ptr = &message[strlen (commands[i].command)]; |
1055 | while (isspace ((int) *ptr)) | 1055 | while (isspace ((int) *ptr)) |
1056 | ptr++; | 1056 | ptr++; |
1057 | if ('\0' == ptr) | ||
1058 | ptr = NULL; | ||
1057 | commands[i].Action (ptr); | 1059 | commands[i].Action (ptr); |
1058 | } | 1060 | } |
1059 | 1061 | ||
diff --git a/src/core/core_api.c b/src/core/core_api.c index 34c235bbd..f07d1ca47 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -1424,7 +1424,6 @@ core_mq_ntr (void *cls, size_t size, | |||
1424 | return 0; | 1424 | return 0; |
1425 | } | 1425 | } |
1426 | memcpy (buf, mh, msg_size); | 1426 | memcpy (buf, mh, msg_size); |
1427 | GNUNET_MQ_impl_send_commit (mq); | ||
1428 | GNUNET_MQ_impl_send_continue (mq); | 1427 | GNUNET_MQ_impl_send_continue (mq); |
1429 | return msg_size; | 1428 | return msg_size; |
1430 | } | 1429 | } |
@@ -1448,7 +1447,7 @@ core_mq_send (struct GNUNET_MQ_Handle *mq, | |||
1448 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "core-mq", "Sending queued message (size %u)\n", | 1447 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "core-mq", "Sending queued message (size %u)\n", |
1449 | ntohs (msg->size)); | 1448 | ntohs (msg->size)); |
1450 | mqs->th = GNUNET_CORE_notify_transmit_ready (mqs->core, GNUNET_YES, 0, | 1449 | mqs->th = GNUNET_CORE_notify_transmit_ready (mqs->core, GNUNET_YES, 0, |
1451 | GNUNET_TIME_UNIT_FOREVER_REL, | 1450 | GNUNET_TIME_UNIT_FOREVER_REL, |
1452 | &mqs->target, | 1451 | &mqs->target, |
1453 | ntohs (msg->size), core_mq_ntr, mq); | 1452 | ntohs (msg->size), core_mq_ntr, mq); |
1454 | } | 1453 | } |
@@ -1459,7 +1458,7 @@ core_mq_send (struct GNUNET_MQ_Handle *mq, | |||
1459 | * destruction of a message queue. | 1458 | * destruction of a message queue. |
1460 | * Implementations must not free @a mq, but should | 1459 | * Implementations must not free @a mq, but should |
1461 | * take care of @a impl_state. | 1460 | * take care of @a impl_state. |
1462 | * | 1461 | * |
1463 | * @param mq the message queue to destroy | 1462 | * @param mq the message queue to destroy |
1464 | * @param impl_state state of the implementation | 1463 | * @param impl_state state of the implementation |
1465 | */ | 1464 | */ |
@@ -1478,7 +1477,7 @@ core_mq_destroy (struct GNUNET_MQ_Handle *mq, void *impl_state) | |||
1478 | 1477 | ||
1479 | /** | 1478 | /** |
1480 | * Implementation function that cancels the currently sent message. | 1479 | * Implementation function that cancels the currently sent message. |
1481 | * | 1480 | * |
1482 | * @param mq message queue | 1481 | * @param mq message queue |
1483 | * @param impl_state state specific to the implementation | 1482 | * @param impl_state state specific to the implementation |
1484 | */ | 1483 | */ |
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h index 651c698e1..26330f3ee 100644 --- a/src/include/gnunet_mq_lib.h +++ b/src/include/gnunet_mq_lib.h | |||
@@ -389,9 +389,9 @@ GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send, | |||
389 | 389 | ||
390 | 390 | ||
391 | /** | 391 | /** |
392 | * Replace the handlers of a message queue with new handlers. | 392 | * Replace the handlers of a message queue with new handlers. Takes |
393 | * Takes effect immediately, even for messages that already have been received, but for | 393 | * effect immediately, even for messages that already have been |
394 | * with the handler has not been called. | 394 | * received, but for with the handler has not been called. |
395 | * | 395 | * |
396 | * If the message queue does not support receiving messages, | 396 | * If the message queue does not support receiving messages, |
397 | * this function has no effect. | 397 | * this function has no effect. |
@@ -506,16 +506,6 @@ void * | |||
506 | GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq); | 506 | GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq); |
507 | 507 | ||
508 | 508 | ||
509 | /** | ||
510 | * Mark the current message as irrevocably sent, but do not | ||
511 | * proceed with sending the next message. | ||
512 | * Will call the appropriate GNUNET_MQ_NotifyCallback, if any. | ||
513 | * | ||
514 | * @param mq message queue | ||
515 | */ | ||
516 | void | ||
517 | GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq); | ||
518 | |||
519 | /** @} */ /* end of group mq */ | 509 | /** @} */ /* end of group mq */ |
520 | 510 | ||
521 | #endif | 511 | #endif |
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index b35a4dc14..9b18df8dd 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -1710,7 +1710,6 @@ mesh_mq_ntr (void *cls, size_t size, | |||
1710 | GNUNET_assert (msize <= size); | 1710 | GNUNET_assert (msize <= size); |
1711 | memcpy (buf, msg, msize); | 1711 | memcpy (buf, msg, msize); |
1712 | GNUNET_MQ_impl_send_continue (mq); | 1712 | GNUNET_MQ_impl_send_continue (mq); |
1713 | GNUNET_MQ_impl_send_commit (mq); | ||
1714 | return msize; | 1713 | return msize; |
1715 | } | 1714 | } |
1716 | 1715 | ||
diff --git a/src/util/mq.c b/src/util/mq.c index d8659ec40..3cf5da496 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -121,12 +121,6 @@ struct GNUNET_MQ_Handle | |||
121 | struct GNUNET_MQ_Envelope *current_envelope; | 121 | struct GNUNET_MQ_Envelope *current_envelope; |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * Has the current envelope been commited? | ||
125 | * Either GNUNET_YES or GNUNET_NO. | ||
126 | */ | ||
127 | int commited; | ||
128 | |||
129 | /** | ||
130 | * Map of associations, lazily allocated | 124 | * Map of associations, lazily allocated |
131 | */ | 125 | */ |
132 | struct GNUNET_CONTAINER_MultiHashMap32 *assoc_map; | 126 | struct GNUNET_CONTAINER_MultiHashMap32 *assoc_map; |
@@ -265,25 +259,27 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev) | |||
265 | void | 259 | void |
266 | GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) | 260 | GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) |
267 | { | 261 | { |
262 | struct GNUNET_MQ_Envelope *current_envelope; | ||
263 | |||
268 | /* call is only valid if we're actually currently sending | 264 | /* call is only valid if we're actually currently sending |
269 | * a message */ | 265 | * a message */ |
270 | GNUNET_assert (NULL != mq); | 266 | current_envelope = mq->current_envelope; |
271 | GNUNET_assert (NULL != mq->current_envelope); | 267 | GNUNET_assert (NULL != current_envelope); |
272 | GNUNET_assert (GNUNET_YES == mq->commited); | ||
273 | mq->commited = GNUNET_NO; | ||
274 | GNUNET_free (mq->current_envelope); | ||
275 | if (NULL == mq->envelope_head) | 268 | if (NULL == mq->envelope_head) |
276 | { | 269 | { |
277 | mq->current_envelope = NULL; | 270 | mq->current_envelope = NULL; |
278 | return; | ||
279 | } | 271 | } |
280 | 272 | else | |
281 | GNUNET_assert (NULL != mq->envelope_tail); | 273 | { |
282 | GNUNET_assert (NULL != mq->envelope_head); | 274 | mq->current_envelope = mq->envelope_head; |
283 | mq->current_envelope = mq->envelope_head; | 275 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, |
284 | GNUNET_CONTAINER_DLL_remove (mq->envelope_head, mq->envelope_tail, | 276 | mq->envelope_tail, |
285 | mq->current_envelope); | 277 | mq->current_envelope); |
286 | mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); | 278 | mq->send_impl (mq, mq->current_envelope->mh, mq->impl_state); |
279 | } | ||
280 | if (NULL != current_envelope->sent_cb) | ||
281 | current_envelope->sent_cb (current_envelope->sent_cls); | ||
282 | GNUNET_free (current_envelope); | ||
287 | } | 283 | } |
288 | 284 | ||
289 | 285 | ||
@@ -362,25 +358,6 @@ GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq) | |||
362 | } | 358 | } |
363 | 359 | ||
364 | 360 | ||
365 | |||
366 | /** | ||
367 | * Mark the current message as irrevocably sent, but do not | ||
368 | * proceed with sending the next message. | ||
369 | * Will call the appropriate GNUNET_MQ_NotifyCallback, if any. | ||
370 | * | ||
371 | * @param mq message queue | ||
372 | */ | ||
373 | void | ||
374 | GNUNET_MQ_impl_send_commit (struct GNUNET_MQ_Handle *mq) | ||
375 | { | ||
376 | GNUNET_assert (NULL != mq->current_envelope); | ||
377 | GNUNET_assert (GNUNET_NO == mq->commited); | ||
378 | mq->commited = GNUNET_YES; | ||
379 | if (NULL != mq->current_envelope->sent_cb) | ||
380 | mq->current_envelope->sent_cb (mq->current_envelope->sent_cls); | ||
381 | } | ||
382 | |||
383 | |||
384 | struct GNUNET_MQ_Envelope * | 361 | struct GNUNET_MQ_Envelope * |
385 | GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type) | 362 | GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp, uint16_t size, uint16_t type) |
386 | { | 363 | { |
@@ -479,9 +456,6 @@ server_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
479 | 456 | ||
480 | GNUNET_assert (NULL != mq); | 457 | GNUNET_assert (NULL != mq); |
481 | GNUNET_assert (NULL != state); | 458 | GNUNET_assert (NULL != state); |
482 | |||
483 | GNUNET_MQ_impl_send_commit (mq); | ||
484 | |||
485 | state->th = | 459 | state->th = |
486 | GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size), | 460 | GNUNET_SERVER_notify_transmit_ready (state->client, ntohs (msg->size), |
487 | GNUNET_TIME_UNIT_FOREVER_REL, | 461 | GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -596,9 +570,6 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
596 | 570 | ||
597 | GNUNET_assert (NULL != state); | 571 | GNUNET_assert (NULL != state); |
598 | GNUNET_assert (NULL == state->th); | 572 | GNUNET_assert (NULL == state->th); |
599 | |||
600 | GNUNET_MQ_impl_send_commit (mq); | ||
601 | |||
602 | state->th = | 573 | state->th = |
603 | GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size), | 574 | GNUNET_CLIENT_notify_transmit_ready (state->connection, ntohs (msg->size), |
604 | GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, | 575 | GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, |