diff options
Diffstat (limited to 'src/util/mq.c')
-rw-r--r-- | src/util/mq.c | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index 25cf24e11..e644994e8 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -708,92 +708,6 @@ GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp, | |||
708 | 708 | ||
709 | 709 | ||
710 | /** | 710 | /** |
711 | * Transmit a queued message to the session's client. | ||
712 | * | ||
713 | * @param cls consensus session | ||
714 | * @param size number of bytes available in @a buf | ||
715 | * @param buf where the callee should write the message | ||
716 | * @return number of bytes written to @a buf | ||
717 | */ | ||
718 | static size_t | ||
719 | transmit_queued (void *cls, | ||
720 | size_t size, | ||
721 | void *buf) | ||
722 | { | ||
723 | struct GNUNET_MQ_Handle *mq = cls; | ||
724 | struct ServerClientSocketState *state = GNUNET_MQ_impl_state (mq); | ||
725 | const struct GNUNET_MessageHeader *msg = GNUNET_MQ_impl_current (mq); | ||
726 | size_t msg_size; | ||
727 | |||
728 | GNUNET_assert (NULL != buf); | ||
729 | msg_size = ntohs (msg->size); | ||
730 | GNUNET_assert (size >= msg_size); | ||
731 | GNUNET_memcpy (buf, msg, msg_size); | ||
732 | state->th = NULL; | ||
733 | |||
734 | GNUNET_MQ_impl_send_continue (mq); | ||
735 | |||
736 | return msg_size; | ||
737 | } | ||
738 | |||
739 | |||
740 | static void | ||
741 | server_client_destroy_impl (struct GNUNET_MQ_Handle *mq, | ||
742 | void *impl_state) | ||
743 | { | ||
744 | struct ServerClientSocketState *state = impl_state; | ||
745 | |||
746 | if (NULL != state->th) | ||
747 | { | ||
748 | GNUNET_SERVER_notify_transmit_ready_cancel (state->th); | ||
749 | state->th = NULL; | ||
750 | } | ||
751 | |||
752 | GNUNET_assert (NULL != mq); | ||
753 | GNUNET_assert (NULL != state); | ||
754 | GNUNET_SERVER_client_drop (state->client); | ||
755 | GNUNET_free (state); | ||
756 | } | ||
757 | |||
758 | |||
759 | static void | ||
760 | server_client_send_impl (struct GNUNET_MQ_Handle *mq, | ||
761 | const struct GNUNET_MessageHeader *msg, | ||
762 | void *impl_state) | ||
763 | { | ||
764 | GNUNET_assert (NULL != mq); | ||
765 | |||
766 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
767 | "Sending message of type %u and size %u\n", | ||
768 | ntohs (msg->type), ntohs (msg->size)); | ||
769 | |||
770 | struct ServerClientSocketState *state = impl_state; | ||
771 | state->th = GNUNET_SERVER_notify_transmit_ready (state->client, | ||
772 | ntohs (msg->size), | ||
773 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
774 | &transmit_queued, | ||
775 | mq); | ||
776 | } | ||
777 | |||
778 | |||
779 | struct GNUNET_MQ_Handle * | ||
780 | GNUNET_MQ_queue_for_server_client (struct GNUNET_SERVER_Client *client) | ||
781 | { | ||
782 | struct GNUNET_MQ_Handle *mq; | ||
783 | struct ServerClientSocketState *scss; | ||
784 | |||
785 | mq = GNUNET_new (struct GNUNET_MQ_Handle); | ||
786 | scss = GNUNET_new (struct ServerClientSocketState); | ||
787 | mq->impl_state = scss; | ||
788 | scss->client = client; | ||
789 | GNUNET_SERVER_client_keep (client); | ||
790 | mq->send_impl = &server_client_send_impl; | ||
791 | mq->destroy_impl = &server_client_destroy_impl; | ||
792 | return mq; | ||
793 | } | ||
794 | |||
795 | |||
796 | /** | ||
797 | * Associate the assoc_data in mq with a unique request id. | 711 | * Associate the assoc_data in mq with a unique request id. |
798 | * | 712 | * |
799 | * @param mq message queue, id will be unique for the queue | 713 | * @param mq message queue, id will be unique for the queue |