diff options
Diffstat (limited to 'src/core/core_api.c')
-rw-r--r-- | src/core/core_api.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index b6d8f61d2..ed8ce364d 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -204,6 +204,11 @@ disconnect_and_free_peer_entry (void *cls, | |||
204 | pr)); | 204 | pr)); |
205 | GNUNET_MQ_destroy (pr->mq); | 205 | GNUNET_MQ_destroy (pr->mq); |
206 | GNUNET_assert (NULL == pr->mq); | 206 | GNUNET_assert (NULL == pr->mq); |
207 | if (NULL != pr->env) | ||
208 | { | ||
209 | GNUNET_MQ_discard (pr->env); | ||
210 | pr->env = NULL; | ||
211 | } | ||
207 | GNUNET_free (pr); | 212 | GNUNET_free (pr); |
208 | return GNUNET_YES; | 213 | return GNUNET_YES; |
209 | } | 214 | } |
@@ -316,7 +321,7 @@ core_mq_send_impl (struct GNUNET_MQ_Handle *mq, | |||
316 | 321 | ||
317 | /* check message size for sanity */ | 322 | /* check message size for sanity */ |
318 | msize = ntohs (msg->size); | 323 | msize = ntohs (msg->size); |
319 | if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct SendMessage)) | 324 | if (msize >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SendMessage)) |
320 | { | 325 | { |
321 | GNUNET_break (0); | 326 | GNUNET_break (0); |
322 | GNUNET_MQ_impl_send_continue (mq); | 327 | GNUNET_MQ_impl_send_continue (mq); |
@@ -331,7 +336,6 @@ core_mq_send_impl (struct GNUNET_MQ_Handle *mq, | |||
331 | env = GNUNET_MQ_msg (smr, | 336 | env = GNUNET_MQ_msg (smr, |
332 | GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST); | 337 | GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST); |
333 | smr->priority = htonl ((uint32_t) priority); | 338 | smr->priority = htonl ((uint32_t) priority); |
334 | // smr->deadline = GNUNET_TIME_absolute_hton (deadline); | ||
335 | smr->peer = pr->peer; | 339 | smr->peer = pr->peer; |
336 | smr->reserved = htonl (0); | 340 | smr->reserved = htonl (0); |
337 | smr->size = htons (msize); | 341 | smr->size = htons (msize); |
@@ -344,7 +348,6 @@ core_mq_send_impl (struct GNUNET_MQ_Handle *mq, | |||
344 | GNUNET_MESSAGE_TYPE_CORE_SEND, | 348 | GNUNET_MESSAGE_TYPE_CORE_SEND, |
345 | msg); | 349 | msg); |
346 | sm->priority = htonl ((uint32_t) priority); | 350 | sm->priority = htonl ((uint32_t) priority); |
347 | // sm->deadline = GNUNET_TIME_absolute_hton (deadline); | ||
348 | sm->peer = pr->peer; | 351 | sm->peer = pr->peer; |
349 | sm->cork = htonl ((uint32_t) cork); | 352 | sm->cork = htonl ((uint32_t) cork); |
350 | sm->reserved = htonl (0); | 353 | sm->reserved = htonl (0); |
@@ -781,7 +784,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
781 | const struct GNUNET_MQ_MessageHandler *handlers) | 784 | const struct GNUNET_MQ_MessageHandler *handlers) |
782 | { | 785 | { |
783 | struct GNUNET_CORE_Handle *h; | 786 | struct GNUNET_CORE_Handle *h; |
784 | unsigned int hcnt; | ||
785 | 787 | ||
786 | h = GNUNET_new (struct GNUNET_CORE_Handle); | 788 | h = GNUNET_new (struct GNUNET_CORE_Handle); |
787 | h->cfg = cfg; | 789 | h->cfg = cfg; |
@@ -791,19 +793,10 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
791 | h->disconnects = disconnects; | 793 | h->disconnects = disconnects; |
792 | h->peers = GNUNET_CONTAINER_multipeermap_create (128, | 794 | h->peers = GNUNET_CONTAINER_multipeermap_create (128, |
793 | GNUNET_NO); | 795 | GNUNET_NO); |
794 | hcnt = 0; | 796 | h->handlers = GNUNET_MQ_copy_handlers (handlers); |
795 | if (NULL != handlers) | 797 | h->hcnt = GNUNET_MQ_count_handlers (handlers); |
796 | while (NULL != handlers[hcnt].cb) | 798 | GNUNET_assert (h->hcnt < |
797 | hcnt++; | 799 | (GNUNET_MAX_MESSAGE_SIZE - |
798 | h->handlers = GNUNET_new_array (hcnt + 1, | ||
799 | struct GNUNET_MQ_MessageHandler); | ||
800 | if (NULL != handlers) | ||
801 | GNUNET_memcpy (h->handlers, | ||
802 | handlers, | ||
803 | hcnt * sizeof (struct GNUNET_MQ_MessageHandler)); | ||
804 | h->hcnt = hcnt; | ||
805 | GNUNET_assert (hcnt < | ||
806 | (GNUNET_SERVER_MAX_MESSAGE_SIZE - | ||
807 | sizeof (struct InitMessage)) / sizeof (uint16_t)); | 800 | sizeof (struct InitMessage)) / sizeof (uint16_t)); |
808 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 801 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
809 | "Connecting to CORE service\n"); | 802 | "Connecting to CORE service\n"); |
@@ -842,7 +835,7 @@ GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle) | |||
842 | GNUNET_MQ_destroy (handle->mq); | 835 | GNUNET_MQ_destroy (handle->mq); |
843 | handle->mq = NULL; | 836 | handle->mq = NULL; |
844 | } | 837 | } |
845 | GNUNET_free (handle->handlers); | 838 | GNUNET_free_non_null (handle->handlers); |
846 | GNUNET_free (handle); | 839 | GNUNET_free (handle); |
847 | } | 840 | } |
848 | 841 | ||