aboutsummaryrefslogtreecommitdiff
path: root/src/util/mq.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-19 22:40:01 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-19 22:40:01 +0000
commit9a0a4efca26978f8e01513dfa291747e24907e3f (patch)
treed2b3a40c34067f1f5eb7c3178f5b1e3de94b7d55 /src/util/mq.c
parent376a648b42414537e55314e79d3b2d8bb1f39dca (diff)
downloadgnunet-9a0a4efca26978f8e01513dfa291747e24907e3f.tar.gz
gnunet-9a0a4efca26978f8e01513dfa291747e24907e3f.zip
proper shutdown
Diffstat (limited to 'src/util/mq.c')
-rw-r--r--src/util/mq.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/util/mq.c b/src/util/mq.c
index c14b4b91d..33bc077c1 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -512,7 +512,8 @@ GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp,
512 * @return number of bytes written to @a buf 512 * @return number of bytes written to @a buf
513 */ 513 */
514static size_t 514static size_t
515transmit_queued (void *cls, size_t size, 515transmit_queued (void *cls,
516 size_t size,
516 void *buf) 517 void *buf)
517{ 518{
518 struct GNUNET_MQ_Handle *mq = cls; 519 struct GNUNET_MQ_Handle *mq = cls;
@@ -521,7 +522,6 @@ transmit_queued (void *cls, size_t size,
521 size_t msg_size; 522 size_t msg_size;
522 523
523 GNUNET_assert (NULL != buf); 524 GNUNET_assert (NULL != buf);
524
525 msg_size = ntohs (msg->size); 525 msg_size = ntohs (msg->size);
526 GNUNET_assert (size >= msg_size); 526 GNUNET_assert (size >= msg_size);
527 memcpy (buf, msg, msg_size); 527 memcpy (buf, msg, msg_size);
@@ -632,6 +632,7 @@ connection_client_transmit_queued (void *cls,
632 size_t msg_size; 632 size_t msg_size;
633 633
634 GNUNET_assert (NULL != mq); 634 GNUNET_assert (NULL != mq);
635 state->th = NULL;
635 msg = GNUNET_MQ_impl_current (mq); 636 msg = GNUNET_MQ_impl_current (mq);
636 637
637 if (NULL == buf) 638 if (NULL == buf)
@@ -667,6 +668,11 @@ connection_client_destroy_impl (struct GNUNET_MQ_Handle *mq,
667{ 668{
668 struct ClientConnectionState *state = impl_state; 669 struct ClientConnectionState *state = impl_state;
669 670
671 if (NULL != state->th)
672 {
673 GNUNET_CLIENT_notify_transmit_ready_cancel (state->th);
674 state->th = NULL;
675 }
670 GNUNET_CLIENT_disconnect (state->connection); 676 GNUNET_CLIENT_disconnect (state->connection);
671 GNUNET_free (impl_state); 677 GNUNET_free (impl_state);
672} 678}
@@ -684,8 +690,10 @@ connection_client_send_impl (struct GNUNET_MQ_Handle *mq,
684 state->th = 690 state->th =
685 GNUNET_CLIENT_notify_transmit_ready (state->connection, 691 GNUNET_CLIENT_notify_transmit_ready (state->connection,
686 ntohs (msg->size), 692 ntohs (msg->size),
687 GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_NO, 693 GNUNET_TIME_UNIT_FOREVER_REL,
688 &connection_client_transmit_queued, mq); 694 GNUNET_NO,
695 &connection_client_transmit_queued,
696 mq);
689 GNUNET_assert (NULL != state->th); 697 GNUNET_assert (NULL != state->th);
690} 698}
691 699