diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-30 16:58:20 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-30 16:58:20 +0000 |
commit | 6a4c5ee6195fb7a6fcf90b1bae5ca36926e82023 (patch) | |
tree | f541686c7c894be4c74926fad156aae32b3f97ca /src/transport/plugin_transport_tcp.c | |
parent | fb0fd00ae3d28e937b4e15a9aa50b62fb8440268 (diff) | |
download | gnunet-6a4c5ee6195fb7a6fcf90b1bae5ca36926e82023.tar.gz gnunet-6a4c5ee6195fb7a6fcf90b1bae5ca36926e82023.zip |
send receive delay rescheduling support
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 657043c24..09c410f2b 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -779,6 +779,8 @@ tcp_disconnect_session (void *cls, struct Session *session) | |||
779 | GNUNET_SERVER_notify_transmit_ready_cancel (session->transmit_handle); | 779 | GNUNET_SERVER_notify_transmit_ready_cancel (session->transmit_handle); |
780 | session->transmit_handle = NULL; | 780 | session->transmit_handle = NULL; |
781 | } | 781 | } |
782 | plugin->env->unregister_quota_notification (plugin->env->cls, | ||
783 | &session->target, PLUGIN_NAME, session); | ||
782 | session->plugin->env->session_end (session->plugin->env->cls, | 784 | session->plugin->env->session_end (session->plugin->env->cls, |
783 | &session->target, session); | 785 | &session->target, session); |
784 | 786 | ||
@@ -929,6 +931,8 @@ create_session (struct Plugin *plugin, | |||
929 | GNUNET_STATISTICS_update (plugin->env->stats, | 931 | GNUNET_STATISTICS_update (plugin->env->stats, |
930 | gettext_noop ("# TCP sessions active"), 1, GNUNET_NO); | 932 | gettext_noop ("# TCP sessions active"), 1, GNUNET_NO); |
931 | } | 933 | } |
934 | plugin->env->register_quota_notification (plugin->env->cls, | ||
935 | &address->peer, PLUGIN_NAME, session); | ||
932 | session->timeout_task = GNUNET_SCHEDULER_add_delayed ( | 936 | session->timeout_task = GNUNET_SCHEDULER_add_delayed ( |
933 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); | 937 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &session_timeout, session); |
934 | return session; | 938 | return session; |
@@ -1323,6 +1327,41 @@ tcp_plugin_update_session_timeout (void *cls, | |||
1323 | } | 1327 | } |
1324 | 1328 | ||
1325 | /** | 1329 | /** |
1330 | * Task to signal the server that we can continue | ||
1331 | * receiving from the TCP client now. | ||
1332 | * | ||
1333 | * @param cls the `struct Session*` | ||
1334 | * @param tc task context (unused) | ||
1335 | */ | ||
1336 | static void | ||
1337 | delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1338 | { | ||
1339 | struct Session *session = cls; | ||
1340 | |||
1341 | session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; | ||
1342 | reschedule_session_timeout (session); | ||
1343 | |||
1344 | GNUNET_SERVER_receive_done (session->client, GNUNET_OK); | ||
1345 | } | ||
1346 | |||
1347 | static void tcp_plugin_update_inbound_delay (void *cls, | ||
1348 | const struct GNUNET_PeerIdentity *peer, | ||
1349 | struct Session *session, | ||
1350 | struct GNUNET_TIME_Relative delay) | ||
1351 | { | ||
1352 | if (GNUNET_SCHEDULER_NO_TASK == session->receive_delay_task) | ||
1353 | return; | ||
1354 | |||
1355 | LOG(GNUNET_ERROR_TYPE_DEBUG, | ||
1356 | "New inbound delay %llu us\n",delay.rel_value_us); | ||
1357 | |||
1358 | GNUNET_SCHEDULER_cancel (session->receive_delay_task); | ||
1359 | session->receive_delay_task = GNUNET_SCHEDULER_add_delayed (delay, | ||
1360 | &delayed_done, session); | ||
1361 | } | ||
1362 | |||
1363 | |||
1364 | /** | ||
1326 | * Create a new session to transmit data to the target | 1365 | * Create a new session to transmit data to the target |
1327 | * This session will used to send data to this peer and the plugin will | 1366 | * This session will used to send data to this peer and the plugin will |
1328 | * notify us by calling the env->session_end function | 1367 | * notify us by calling the env->session_end function |
@@ -2102,23 +2141,6 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client, | |||
2102 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2141 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2103 | } | 2142 | } |
2104 | 2143 | ||
2105 | /** | ||
2106 | * Task to signal the server that we can continue | ||
2107 | * receiving from the TCP client now. | ||
2108 | * | ||
2109 | * @param cls the `struct Session*` | ||
2110 | * @param tc task context (unused) | ||
2111 | */ | ||
2112 | static void | ||
2113 | delayed_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2114 | { | ||
2115 | struct Session *session = cls; | ||
2116 | |||
2117 | session->receive_delay_task = GNUNET_SCHEDULER_NO_TASK; | ||
2118 | reschedule_session_timeout (session); | ||
2119 | |||
2120 | GNUNET_SERVER_receive_done (session->client, GNUNET_OK); | ||
2121 | } | ||
2122 | 2144 | ||
2123 | /** | 2145 | /** |
2124 | * We've received data for this peer via TCP. Unbox, | 2146 | * We've received data for this peer via TCP. Unbox, |
@@ -2479,6 +2501,7 @@ else | |||
2479 | api->string_to_address = &tcp_string_to_address; | 2501 | api->string_to_address = &tcp_string_to_address; |
2480 | api->get_network = &tcp_get_network; | 2502 | api->get_network = &tcp_get_network; |
2481 | api->update_session_timeout = &tcp_plugin_update_session_timeout; | 2503 | api->update_session_timeout = &tcp_plugin_update_session_timeout; |
2504 | api->update_inbound_delay = &tcp_plugin_update_inbound_delay; | ||
2482 | plugin->service = service; | 2505 | plugin->service = service; |
2483 | if (NULL != service) | 2506 | if (NULL != service) |
2484 | { | 2507 | { |