diff options
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index e4942248a..0643663b3 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -61,15 +61,6 @@ client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls) | |||
61 | } | 61 | } |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | int | ||
65 | client_send (struct Session *s, struct HTTP_Message *msg) | ||
66 | { | ||
67 | GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); | ||
68 | if (s != NULL) | ||
69 | curl_easy_pause(s->client_put, CURLPAUSE_CONT); | ||
70 | return GNUNET_OK; | ||
71 | } | ||
72 | |||
73 | /** | 64 | /** |
74 | * Task performing curl operations | 65 | * Task performing curl operations |
75 | * @param cls plugin as closure | 66 | * @param cls plugin as closure |
@@ -148,6 +139,25 @@ client_schedule (struct Plugin *plugin) | |||
148 | } | 139 | } |
149 | 140 | ||
150 | 141 | ||
142 | int | ||
143 | client_send (struct Session *s, struct HTTP_Message *msg) | ||
144 | { | ||
145 | GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); | ||
146 | |||
147 | if ((s != NULL) && (s->client_put_paused == GNUNET_YES)) | ||
148 | { | ||
149 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, "Client: %X was suspended, unpausing\n", s->client_put); | ||
150 | s->client_put_paused = GNUNET_NO; | ||
151 | curl_easy_pause(s->client_put, CURLPAUSE_CONT); | ||
152 | } | ||
153 | |||
154 | client_schedule (s->plugin); | ||
155 | |||
156 | return GNUNET_OK; | ||
157 | } | ||
158 | |||
159 | |||
160 | |||
151 | /** | 161 | /** |
152 | * Task performing curl operations | 162 | * Task performing curl operations |
153 | * @param cls plugin as closure | 163 | * @param cls plugin as closure |
@@ -335,16 +345,19 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
335 | struct Session *s = cls; | 345 | struct Session *s = cls; |
336 | struct Plugin *plugin = s->plugin; | 346 | struct Plugin *plugin = s->plugin; |
337 | struct GNUNET_TIME_Absolute now; | 347 | struct GNUNET_TIME_Absolute now; |
348 | size_t len = size * nmemb; | ||
349 | |||
338 | 350 | ||
339 | #if VERBOSE_CLIENT | 351 | #if VERBOSE_CLIENT |
340 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received %Zu bytes from peer `%s'\n", | 352 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received %Zu bytes from peer `%s'\n", |
341 | size * nmemb, | 353 | len, |
342 | GNUNET_i2s (&s->target)); | 354 | GNUNET_i2s (&s->target)); |
343 | #endif | 355 | #endif |
344 | 356 | ||
345 | now = GNUNET_TIME_absolute_get(); | 357 | now = GNUNET_TIME_absolute_get(); |
346 | if (now.abs_value < s->delay.abs_value) | 358 | if (now.abs_value < s->delay.abs_value) |
347 | { | 359 | { |
360 | #if 0 | ||
348 | #if DEBUG_CLIENT | 361 | #if DEBUG_CLIENT |
349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
350 | "No inbound bandwidth available! Next read was delayed for %llu ms\n", | 363 | "No inbound bandwidth available! Next read was delayed for %llu ms\n", |
@@ -357,16 +370,19 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
357 | } | 370 | } |
358 | s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed( GNUNET_TIME_absolute_get_difference(s->delay, now), &client_wake_up, s); | 371 | s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed( GNUNET_TIME_absolute_get_difference(s->delay, now), &client_wake_up, s); |
359 | return CURLPAUSE_ALL; | 372 | return CURLPAUSE_ALL; |
373 | #endif | ||
360 | } | 374 | } |
361 | 375 | ||
362 | 376 | ||
363 | if (s->msg_tk == NULL) | 377 | if (s->msg_tk == NULL) |
364 | s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s); | 378 | s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s); |
365 | 379 | ||
366 | GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, size * nmemb, GNUNET_NO, | 380 | GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, |
367 | GNUNET_NO); | 381 | GNUNET_NO); |
368 | 382 | ||
369 | return (size * nmemb); | 383 | return len; |
384 | |||
385 | client_wake_up (NULL, NULL); | ||
370 | } | 386 | } |
371 | 387 | ||
372 | /** | 388 | /** |
@@ -376,7 +392,7 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
376 | * @param size size of an individual element | 392 | * @param size size of an individual element |
377 | * @param nmemb count of elements that can be written to the buffer | 393 | * @param nmemb count of elements that can be written to the buffer |
378 | * @param ptr source pointer, passed to the libcurl handle | 394 | * @param ptr source pointer, passed to the libcurl handle |
379 | * @return bytes written to stream | 395 | * @return bytes written to stream, returning 0 will terminate connection! |
380 | */ | 396 | */ |
381 | static size_t | 397 | static size_t |
382 | client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | 398 | client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) |
@@ -401,7 +417,12 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
401 | } | 417 | } |
402 | */ | 418 | */ |
403 | if (msg == NULL) | 419 | if (msg == NULL) |
404 | return bytes_sent; | 420 | { |
421 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: %X Nothing to send! Suspending PUT handle!\n", s->client_put); | ||
422 | s->client_put_paused = GNUNET_YES; | ||
423 | return CURL_READFUNC_PAUSE; | ||
424 | } | ||
425 | |||
405 | GNUNET_assert (msg != NULL); | 426 | GNUNET_assert (msg != NULL); |
406 | /* data to send */ | 427 | /* data to send */ |
407 | if (msg->pos < msg->size) | 428 | if (msg->pos < msg->size) |