diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-26 15:58:11 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-26 15:58:11 +0000 |
commit | 5c9b9bac3b0a6f1e090342e460f6393c68492797 (patch) | |
tree | 5159d609684d830de783fc0ccf090073ae979f1f | |
parent | eea392cfb326b6cd3eadaf74ffd8e71d570d235e (diff) | |
download | gnunet-5c9b9bac3b0a6f1e090342e460f6393c68492797.tar.gz gnunet-5c9b9bac3b0a6f1e090342e460f6393c68492797.zip |
fixed:
- session matching
- curl send handle suspending
-rw-r--r-- | src/transport/plugin_transport_http.h | 2 | ||||
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 49 | ||||
-rw-r--r-- | src/transport/plugin_transport_http_new.c | 16 |
3 files changed, 47 insertions, 20 deletions
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 249b92c9d..7120accfb 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h | |||
@@ -244,7 +244,7 @@ struct Session | |||
244 | 244 | ||
245 | void *client_put; | 245 | void *client_put; |
246 | void *client_get; | 246 | void *client_get; |
247 | int put_paused; | 247 | int client_put_paused; |
248 | 248 | ||
249 | void *server_recv; | 249 | void *server_recv; |
250 | void *server_send; | 250 | void *server_send; |
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) |
diff --git a/src/transport/plugin_transport_http_new.c b/src/transport/plugin_transport_http_new.c index 2c7037694..042c977f5 100644 --- a/src/transport/plugin_transport_http_new.c +++ b/src/transport/plugin_transport_http_new.c | |||
@@ -340,6 +340,12 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
340 | return NULL; | 340 | return NULL; |
341 | while (t != NULL) | 341 | while (t != NULL) |
342 | { | 342 | { |
343 | #if 0 | ||
344 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | ||
345 | "Comparing peer `%s' address `%s' len %i session %X to \n", GNUNET_i2s(target), GNUNET_a2s(addr,addrlen), addrlen, session); | ||
346 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"peer `%s' address `%s' len %i session %X \n\n", GNUNET_i2s(&t->target), GNUNET_a2s(t->addr,t->addrlen), t->addrlen, t); | ||
347 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"memcmp %i \n", memcmp (addr, t->addr, addrlen)); | ||
348 | #endif | ||
343 | e_peer = GNUNET_NO; | 349 | e_peer = GNUNET_NO; |
344 | e_addr = GNUNET_NO; | 350 | e_addr = GNUNET_NO; |
345 | 351 | ||
@@ -348,7 +354,7 @@ lookup_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
348 | e_peer = GNUNET_YES; | 354 | e_peer = GNUNET_YES; |
349 | if (addrlen == t->addrlen) | 355 | if (addrlen == t->addrlen) |
350 | { | 356 | { |
351 | if (0 == memcmp (addr, &t->addr, addrlen)) | 357 | if (0 == memcmp (addr, t->addr, addrlen)) |
352 | { | 358 | { |
353 | e_addr = GNUNET_YES; | 359 | e_addr = GNUNET_YES; |
354 | } | 360 | } |
@@ -492,7 +498,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
492 | s = lookup_session (plugin, target, session, addr, addrlen, 1); | 498 | s = lookup_session (plugin, target, session, addr, addrlen, 1); |
493 | #if DEBUG_HTTP | 499 | #if DEBUG_HTTP |
494 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 500 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
495 | "%s exisiting session\n", (s!=NULL) ? "Found" : "NOT Found"); | 501 | "%s existing session: %s\n", (s!=NULL) ? "Found" : "NOT Found", ((s != NULL) && (s->inbound == GNUNET_YES)) ? "inbound" : "outbound"); |
496 | #endif | 502 | #endif |
497 | 503 | ||
498 | /* create new outbound connection */ | 504 | /* create new outbound connection */ |
@@ -749,7 +755,7 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
749 | { | 755 | { |
750 | GNUNET_assert (cls != NULL); | 756 | GNUNET_assert (cls != NULL); |
751 | struct Plugin *plugin = cls; | 757 | struct Plugin *plugin = cls; |
752 | //static int limit; | 758 | static int limit; |
753 | #if DEBUG_HTTP | 759 | #if DEBUG_HTTP |
754 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 760 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
755 | "NPMC called %s to address `%s'\n", | 761 | "NPMC called %s to address `%s'\n", |
@@ -761,9 +767,9 @@ nat_port_map_callback (void *cls, int add_remove, const struct sockaddr *addr, | |||
761 | { | 767 | { |
762 | case GNUNET_YES: | 768 | case GNUNET_YES: |
763 | // FIXME DEBUGGING | 769 | // FIXME DEBUGGING |
764 | //if (limit < 1) | 770 | if (limit < 1) |
765 | nat_add_address (cls, add_remove, addr, addrlen); | 771 | nat_add_address (cls, add_remove, addr, addrlen); |
766 | //limit++; | 772 | limit++; |
767 | // FIXME END | 773 | // FIXME END |
768 | break; | 774 | break; |
769 | case GNUNET_NO: | 775 | case GNUNET_NO: |