diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-18 02:23:43 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-18 02:23:43 +0000 |
commit | 28653a4922fd5a2d8fb7f72d799c9e79a2400abe (patch) | |
tree | 6512c6305a85783ff40fef1b4a405084a44cc98a /src/mesh/gnunet-service-mesh_channel.c | |
parent | b77d61f1ee16dca21c147e09623abe9c121667b7 (diff) | |
download | gnunet-28653a4922fd5a2d8fb7f72d799c9e79a2400abe.tar.gz gnunet-28653a4922fd5a2d8fb7f72d799c9e79a2400abe.zip |
- flow control changes and fixes
Diffstat (limited to 'src/mesh/gnunet-service-mesh_channel.c')
-rw-r--r-- | src/mesh/gnunet-service-mesh_channel.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index b02da1aba..519dda89d 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c | |||
@@ -143,6 +143,11 @@ struct MeshChannelReliability | |||
143 | */ | 143 | */ |
144 | int client_ready; | 144 | int client_ready; |
145 | 145 | ||
146 | /** | ||
147 | * Can the client send data to us? | ||
148 | */ | ||
149 | int client_allowed; | ||
150 | |||
146 | /** | 151 | /** |
147 | * Task to resend/poll in case no ACK is received. | 152 | * Task to resend/poll in case no ACK is received. |
148 | */ | 153 | */ |
@@ -465,6 +470,13 @@ send_client_ack (struct MeshChannel *ch, int fwd) | |||
465 | return; | 470 | return; |
466 | } | 471 | } |
467 | 472 | ||
473 | if (GNUNET_YES == rel->client_allowed) | ||
474 | { | ||
475 | LOG (GNUNET_ERROR_TYPE_DEBUG, " already allowed\n"); | ||
476 | return; | ||
477 | } | ||
478 | rel->client_allowed = GNUNET_YES; | ||
479 | |||
468 | GML_send_ack (fwd ? ch->root : ch->dest, fwd ? ch->lid_root : ch->lid_dest); | 480 | GML_send_ack (fwd ? ch->root : ch->dest, fwd ? ch->lid_root : ch->lid_dest); |
469 | } | 481 | } |
470 | 482 | ||
@@ -997,6 +1009,25 @@ GMCH_get_buffer (struct MeshChannel *ch, int fwd) | |||
997 | 1009 | ||
998 | 1010 | ||
999 | /** | 1011 | /** |
1012 | * Get flow control status of end point: is client allow to send? | ||
1013 | * | ||
1014 | * @param ch Channel. | ||
1015 | * @param fwd Is query about FWD traffic? (Request root status). | ||
1016 | * | ||
1017 | * @return GNUNET_YES if client is allowed to send us data. | ||
1018 | */ | ||
1019 | int | ||
1020 | GMCH_get_allowed (struct MeshChannel *ch, int fwd) | ||
1021 | { | ||
1022 | struct MeshChannelReliability *rel; | ||
1023 | |||
1024 | rel = fwd ? ch->root_rel : ch->dest_rel; | ||
1025 | |||
1026 | return rel->client_allowed; | ||
1027 | } | ||
1028 | |||
1029 | |||
1030 | /** | ||
1000 | * Is the root client for this channel on this peer? | 1031 | * Is the root client for this channel on this peer? |
1001 | * | 1032 | * |
1002 | * @param ch Channel. | 1033 | * @param ch Channel. |
@@ -1152,6 +1183,19 @@ GMCH_send_data_ack (struct MeshChannel *ch, int fwd) | |||
1152 | 1183 | ||
1153 | 1184 | ||
1154 | /** | 1185 | /** |
1186 | * Allow a client to send us more data, in case it was choked. | ||
1187 | * | ||
1188 | * @param ch Channel. | ||
1189 | * @param fwd Is this about FWD traffic? (Root client). | ||
1190 | */ | ||
1191 | void | ||
1192 | GMCH_allow_client (struct MeshChannel *ch, int fwd) | ||
1193 | { | ||
1194 | send_client_ack (ch, fwd); | ||
1195 | } | ||
1196 | |||
1197 | |||
1198 | /** | ||
1155 | * Log channel info. | 1199 | * Log channel info. |
1156 | * | 1200 | * |
1157 | * @param ch Channel. | 1201 | * @param ch Channel. |
@@ -1206,7 +1250,7 @@ GMCH_handle_local_ack (struct MeshChannel *ch, int fwd) | |||
1206 | 1250 | ||
1207 | rel->client_ready = GNUNET_YES; | 1251 | rel->client_ready = GNUNET_YES; |
1208 | send_client_buffered_data (ch, c, fwd); | 1252 | send_client_buffered_data (ch, c, fwd); |
1209 | GMC_send_ack (NULL, ch, fwd); | 1253 | GMT_send_acks (ch->t, fwd); |
1210 | } | 1254 | } |
1211 | 1255 | ||
1212 | 1256 | ||
@@ -1247,6 +1291,8 @@ GMCH_handle_local_data (struct MeshChannel *ch, | |||
1247 | 1291 | ||
1248 | rel = fwd ? ch->root_rel : ch->dest_rel; | 1292 | rel = fwd ? ch->root_rel : ch->dest_rel; |
1249 | 1293 | ||
1294 | rel->client_allowed = GNUNET_NO; | ||
1295 | |||
1250 | /* Ok, everything is correct, send the message. */ | 1296 | /* Ok, everything is correct, send the message. */ |
1251 | payload = (struct GNUNET_MESH_Data *) cbuf; | 1297 | payload = (struct GNUNET_MESH_Data *) cbuf; |
1252 | payload->mid = htonl (rel->mid_send); | 1298 | payload->mid = htonl (rel->mid_send); |