aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-09 20:01:13 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-09 20:01:13 +0000
commit5332743767668b529282ae8877c21c706575558c (patch)
tree7b2ab085a068381e7a800b4afd195947385dd532 /src/core
parent31381126c231ddbfcf35d659b47bc44f33bd4e07 (diff)
downloadgnunet-5332743767668b529282ae8877c21c706575558c.tar.gz
gnunet-5332743767668b529282ae8877c21c706575558c.zip
-code simplification
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core_api.c112
1 files changed, 55 insertions, 57 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index c3dc4c9ec..4ec72e457 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -555,7 +555,7 @@ transmission_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
555 } 555 }
556 LOG (GNUNET_ERROR_TYPE_DEBUG, 556 LOG (GNUNET_ERROR_TYPE_DEBUG,
557 "Signalling timeout of request for transmission to CORE service\n"); 557 "Signalling timeout of request for transmission to CORE service\n");
558 request_next_transmission (pr); 558 trigger_next_request (h, GNUNET_NO);
559 GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL)); 559 GNUNET_assert (0 == th->get_message (th->get_message_cls, 0, NULL));
560} 560}
561 561
@@ -614,65 +614,63 @@ transmit_message (void *cls, size_t size, void *buf)
614 return msize; 614 return msize;
615 } 615 }
616 /* now check for 'ready' P2P messages */ 616 /* now check for 'ready' P2P messages */
617 if (NULL != (pr = h->ready_peer_head)) 617 if (NULL == (pr = h->ready_peer_head))
618 return 0;
619 GNUNET_assert (NULL != pr->th.peer);
620 th = &pr->th;
621 if (size < th->msize + sizeof (struct SendMessage))
622 {
623 trigger_next_request (h, GNUNET_NO);
624 return 0;
625 }
626 GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
627 th->peer = NULL;
628 if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
629 {
630 GNUNET_SCHEDULER_cancel (pr->timeout_task);
631 pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
632 }
633 LOG (GNUNET_ERROR_TYPE_DEBUG,
634 "Transmitting SEND request to `%s' with %u bytes.\n",
635 GNUNET_i2s (&pr->peer), (unsigned int) th->msize);
636 sm = (struct SendMessage *) buf;
637 sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
638 sm->priority = htonl (th->priority);
639 sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
640 sm->peer = pr->peer;
641 sm->cork = htonl ((uint32_t) th->cork);
642 sm->reserved = htonl (0);
643 ret =
644 th->get_message (th->get_message_cls,
645 size - sizeof (struct SendMessage), &sm[1]);
646
647 LOG (GNUNET_ERROR_TYPE_DEBUG,
648 "Transmitting SEND request to `%s' yielded %u bytes.\n",
649 GNUNET_i2s (&pr->peer), ret);
650 if (0 == ret)
618 { 651 {
619 GNUNET_assert (NULL != pr->th.peer);
620 th = &pr->th;
621 if (size < th->msize + sizeof (struct SendMessage))
622 {
623 trigger_next_request (h, GNUNET_NO);
624 return 0;
625 }
626 GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr);
627 th->peer = NULL;
628 if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK)
629 {
630 GNUNET_SCHEDULER_cancel (pr->timeout_task);
631 pr->timeout_task = GNUNET_SCHEDULER_NO_TASK;
632 }
633 LOG (GNUNET_ERROR_TYPE_DEBUG,
634 "Transmitting SEND request to `%s' with %u bytes.\n",
635 GNUNET_i2s (&pr->peer), (unsigned int) th->msize);
636 sm = (struct SendMessage *) buf;
637 sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
638 sm->priority = htonl (th->priority);
639 sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
640 sm->peer = pr->peer;
641 sm->cork = htonl ((uint32_t) th->cork);
642 sm->reserved = htonl (0);
643 ret =
644 th->get_message (th->get_message_cls,
645 size - sizeof (struct SendMessage), &sm[1]);
646
647 LOG (GNUNET_ERROR_TYPE_DEBUG,
648 "Transmitting SEND request to `%s' yielded %u bytes.\n",
649 GNUNET_i2s (&pr->peer), ret);
650 if (0 == ret)
651 {
652 LOG (GNUNET_ERROR_TYPE_DEBUG,
653 "Size of clients message to peer %s is 0!\n",
654 GNUNET_i2s (&pr->peer));
655 /* client decided to send nothing! */
656 request_next_transmission (pr);
657 return 0;
658 }
659 LOG (GNUNET_ERROR_TYPE_DEBUG, 652 LOG (GNUNET_ERROR_TYPE_DEBUG,
660 "Produced SEND message to core with %u bytes payload\n", 653 "Size of clients message to peer %s is 0!\n",
661 (unsigned int) ret); 654 GNUNET_i2s (&pr->peer));
662 GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader)); 655 /* client decided to send nothing! */
663 if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
664 {
665 GNUNET_break (0);
666 request_next_transmission (pr);
667 return 0;
668 }
669 ret += sizeof (struct SendMessage);
670 sm->header.size = htons (ret);
671 GNUNET_assert (ret <= size);
672 request_next_transmission (pr); 656 request_next_transmission (pr);
673 return ret; 657 return 0;
674 } 658 }
675 return 0; 659 LOG (GNUNET_ERROR_TYPE_DEBUG,
660 "Produced SEND message to core with %u bytes payload\n",
661 (unsigned int) ret);
662 GNUNET_assert (ret >= sizeof (struct GNUNET_MessageHeader));
663 if (ret + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
664 {
665 GNUNET_break (0);
666 request_next_transmission (pr);
667 return 0;
668 }
669 ret += sizeof (struct SendMessage);
670 sm->header.size = htons (ret);
671 GNUNET_assert (ret <= size);
672 request_next_transmission (pr);
673 return ret;
676} 674}
677 675
678 676
@@ -1295,7 +1293,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
1295 if (NULL != pr->th.peer) 1293 if (NULL != pr->th.peer)
1296 { 1294 {
1297 /* attempting to queue a second request for the same destination */ 1295 /* attempting to queue a second request for the same destination */
1298 GNUNET_break (0); 1296 GNUNET_assert (0);
1299 return NULL; 1297 return NULL;
1300 } 1298 }
1301 GNUNET_assert (notify_size + sizeof (struct SendMessage) < 1299 GNUNET_assert (notify_size + sizeof (struct SendMessage) <