diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-05-21 16:56:26 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-05-21 16:56:26 +0200 |
commit | c6777519ba8ef594b999209bac79a7f4b37ff30c (patch) | |
tree | eca632a176defb061577ae0b0b7539d10f63e0c6 | |
parent | 49227270d760cf72978eeec8d0684b855deea526 (diff) | |
download | gnunet-c6777519ba8ef594b999209bac79a7f4b37ff30c.tar.gz gnunet-c6777519ba8ef594b999209bac79a7f4b37ff30c.zip |
implement GNUNET_TRANSPORT_core_receive_continue
-rw-r--r-- | src/transport/transport_api_core.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/transport/transport_api_core.c b/src/transport/transport_api_core.c index 54dc7f4c3..224af5de2 100644 --- a/src/transport/transport_api_core.c +++ b/src/transport/transport_api_core.c | |||
@@ -180,6 +180,15 @@ struct GNUNET_TRANSPORT_CoreHandle | |||
180 | struct GNUNET_TIME_Relative reconnect_delay; | 180 | struct GNUNET_TIME_Relative reconnect_delay; |
181 | 181 | ||
182 | /** | 182 | /** |
183 | * Internal counter to check how many more receive OK messages this | ||
184 | * CORE service is allowed to send in total. Just to detect easy | ||
185 | * cases of protocol violations by the CORE implementation. | ||
186 | * NOTE: we may want to make this stronger by counting per peer | ||
187 | * instead of globally. | ||
188 | */ | ||
189 | unsigned int rom_pending; | ||
190 | |||
191 | /** | ||
183 | * Should we check that @e self matches what the service thinks? | 192 | * Should we check that @e self matches what the service thinks? |
184 | * (if #GNUNET_NO, then @e self is all zeros!). | 193 | * (if #GNUNET_NO, then @e self is all zeros!). |
185 | */ | 194 | */ |
@@ -695,6 +704,7 @@ handle_recv (void *cls, const struct InboundMessage *im) | |||
695 | disconnect_and_schedule_reconnect (h); | 704 | disconnect_and_schedule_reconnect (h); |
696 | return; | 705 | return; |
697 | } | 706 | } |
707 | h->rom_pending++; | ||
698 | GNUNET_MQ_inject_message (n->mq, imm); | 708 | GNUNET_MQ_inject_message (n->mq, imm); |
699 | } | 709 | } |
700 | 710 | ||
@@ -919,4 +929,40 @@ GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle) | |||
919 | } | 929 | } |
920 | 930 | ||
921 | 931 | ||
932 | /** | ||
933 | * Notification from the CORE service to the TRANSPORT service | ||
934 | * that the CORE service has finished processing a message from | ||
935 | * TRANSPORT (via the @code{handlers} of #GNUNET_TRANSPORT_core_connect()) | ||
936 | * and that it is thus now OK for TRANSPORT to send more messages | ||
937 | * for @a pid. | ||
938 | * | ||
939 | * Used to provide flow control, this is our equivalent to | ||
940 | * #GNUNET_SERVICE_client_continue() of an ordinary service. | ||
941 | * | ||
942 | * Note that due to the use of a window, TRANSPORT may send multiple | ||
943 | * messages destined for the same peer even without an intermediate | ||
944 | * call to this function. However, CORE must still call this function | ||
945 | * once per message received, as otherwise eventually the window will | ||
946 | * be full and TRANSPORT will stop providing messages to CORE for @a | ||
947 | * pid. | ||
948 | * | ||
949 | * @param ch core handle | ||
950 | * @param pid which peer was the message from that was fully processed by CORE | ||
951 | */ | ||
952 | void | ||
953 | GNUNET_TRANSPORT_core_receive_continue (struct GNUNET_TRANSPORT_CoreHandle *ch, | ||
954 | const struct GNUNET_PeerIdentity *pid) | ||
955 | { | ||
956 | struct RecvOkMessage *rom; | ||
957 | struct GNUNET_MQ_Envelope *env; | ||
958 | |||
959 | GNUNET_assert (ch->rom_pending > 0); | ||
960 | ch->rom_pending--; | ||
961 | env = GNUNET_MQ_msg (rom, GNUNET_MESSAGE_TYPE_TRANSPORT_RECV_OK); | ||
962 | rom->increase_window_delta = htonl (1); | ||
963 | rom->peer = *pid; | ||
964 | GNUNET_MQ_send (ch->mq, env); | ||
965 | } | ||
966 | |||
967 | |||
922 | /* end of transport_api_core.c */ | 968 | /* end of transport_api_core.c */ |