aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-26 21:12:56 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-26 21:12:56 +0000
commit8c2dc7d19810d58f23c43bf900e2fb3eebe06fed (patch)
tree9173a966e2f51a34d9259a0126484e05d44dcaac /src/core/core_api.c
parenta89ea716333ad5ad43757a946efc01cb5e95a0c0 (diff)
downloadgnunet-8c2dc7d19810d58f23c43bf900e2fb3eebe06fed.tar.gz
gnunet-8c2dc7d19810d58f23c43bf900e2fb3eebe06fed.zip
-converting CORE service to new transport MQ API
Diffstat (limited to 'src/core/core_api.c')
-rw-r--r--src/core/core_api.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c
index dd912ac22..caf614afc 100644
--- a/src/core/core_api.c
+++ b/src/core/core_api.c
@@ -674,6 +674,8 @@ handle_send_ready (void *cls,
674 struct GNUNET_TIME_Relative delay; 674 struct GNUNET_TIME_Relative delay;
675 struct GNUNET_TIME_Relative overdue; 675 struct GNUNET_TIME_Relative overdue;
676 unsigned int ret; 676 unsigned int ret;
677 unsigned int priority;
678 int cork;
677 679
678 GNUNET_break (GNUNET_NO == h->currently_down); 680 GNUNET_break (GNUNET_NO == h->currently_down);
679 pr = GNUNET_CONTAINER_multipeermap_get (h->peers, 681 pr = GNUNET_CONTAINER_multipeermap_get (h->peers,
@@ -708,11 +710,12 @@ handle_send_ready (void *cls,
708 sm->priority = htonl ((uint32_t) th->priority); 710 sm->priority = htonl ((uint32_t) th->priority);
709 sm->deadline = GNUNET_TIME_absolute_hton (th->deadline); 711 sm->deadline = GNUNET_TIME_absolute_hton (th->deadline);
710 sm->peer = pr->peer; 712 sm->peer = pr->peer;
711 sm->cork = htonl ((uint32_t) th->cork); 713 sm->cork = htonl ((uint32_t) (cork = th->cork));
712 sm->reserved = htonl (0); 714 sm->reserved = htonl (0);
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 715 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
714 "Calling get_message with buffer of %u bytes\n", 716 "Calling get_message with buffer of %u bytes (%s)\n",
715 (unsigned int) th->msize); 717 (unsigned int) th->msize,
718 cork ? "corked" : "uncorked");
716 /* FIXME: this is ugly and a bit brutal, but "get_message" 719 /* FIXME: this is ugly and a bit brutal, but "get_message"
717 may call GNUNET_CORE_notify_transmit_ready() which 720 may call GNUNET_CORE_notify_transmit_ready() which
718 may call GNUNET_MQ_send() as well, and we MUST get this 721 may call GNUNET_MQ_send() as well, and we MUST get this
@@ -725,30 +728,33 @@ handle_send_ready (void *cls,
725 be required */ 728 be required */
726 GNUNET_MQ_send (h->mq, 729 GNUNET_MQ_send (h->mq,
727 env); 730 env);
731 delay = GNUNET_TIME_absolute_get_duration (th->request_time);
732 overdue = GNUNET_TIME_absolute_get_duration (th->deadline);
733 priority = th->priority;
728 ret = th->get_message (th->get_message_cls, 734 ret = th->get_message (th->get_message_cls,
729 th->msize, 735 th->msize,
730 &sm[1]); 736 &sm[1]);
737 /* after this point, 'th' should not be used anymore, it
738 may now be about another message! */
731 sm->header.size = htons (ret + sizeof (struct SendMessage)); 739 sm->header.size = htons (ret + sizeof (struct SendMessage));
732 delay = GNUNET_TIME_absolute_get_duration (th->request_time);
733 overdue = GNUNET_TIME_absolute_get_duration (th->deadline);
734 if (overdue.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) 740 if (overdue.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
735 LOG (GNUNET_ERROR_TYPE_WARNING, 741 LOG (GNUNET_ERROR_TYPE_WARNING,
736 "Transmitting overdue %u bytes to `%s' at priority %u with %s delay %s\n", 742 "Transmitting overdue %u bytes to `%s' at priority %u with %s delay %s\n",
737 ret, 743 ret,
738 GNUNET_i2s (&pr->peer), 744 GNUNET_i2s (&pr->peer),
739 (unsigned int) th->priority, 745 priority,
740 GNUNET_STRINGS_relative_time_to_string (delay, 746 GNUNET_STRINGS_relative_time_to_string (delay,
741 GNUNET_YES), 747 GNUNET_YES),
742 (th->cork) ? " (corked)" : ""); 748 (cork) ? " (corked)" : " (uncorked)");
743 else 749 else
744 LOG (GNUNET_ERROR_TYPE_DEBUG, 750 LOG (GNUNET_ERROR_TYPE_DEBUG,
745 "Transmitting %u bytes to `%s' at priority %u with %s delay %s\n", 751 "Transmitting %u bytes to `%s' at priority %u with %s delay %s\n",
746 ret, 752 ret,
747 GNUNET_i2s (&pr->peer), 753 GNUNET_i2s (&pr->peer),
748 (unsigned int) th->priority, 754 priority,
749 GNUNET_STRINGS_relative_time_to_string (delay, 755 GNUNET_STRINGS_relative_time_to_string (delay,
750 GNUNET_YES), 756 GNUNET_YES),
751 (th->cork) ? " (corked)" : ""); 757 (cork) ? " (corked)" : " (uncorked)");
752} 758}
753 759
754 760
@@ -995,9 +1001,10 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
995 return NULL; 1001 return NULL;
996 } 1002 }
997 LOG (GNUNET_ERROR_TYPE_DEBUG, 1003 LOG (GNUNET_ERROR_TYPE_DEBUG,
998 "Asking core for transmission of %u bytes to `%s'\n", 1004 "Asking core for transmission of %u bytes to `%s'%s\n",
999 (unsigned int) notify_size, 1005 (unsigned int) notify_size,
1000 GNUNET_i2s (target)); 1006 GNUNET_i2s (target),
1007 cork ? " (corked)" : "");
1001 pr = GNUNET_CONTAINER_multipeermap_get (handle->peers, 1008 pr = GNUNET_CONTAINER_multipeermap_get (handle->peers,
1002 target); 1009 target);
1003 if (NULL == pr) 1010 if (NULL == pr)