diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-26 11:37:50 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-26 11:37:50 +0000 |
commit | 435eded3cf216363f75e1904254c22c7c5fd987a (patch) | |
tree | 00a06f617239fec39770968c423294953fab2e3e /src/transport/plugin_transport_http_client.c | |
parent | 074ec517f192b7a74b1180c20144facf4cf8cf7d (diff) | |
download | gnunet-435eded3cf216363f75e1904254c22c7c5fd987a.tar.gz gnunet-435eded3cf216363f75e1904254c22c7c5fd987a.zip |
- fix for http
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index b079c1732..eefc98b2e 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -26,6 +26,8 @@ | |||
26 | 26 | ||
27 | #include "plugin_transport_http.h" | 27 | #include "plugin_transport_http.h" |
28 | 28 | ||
29 | static struct Plugin * p; | ||
30 | |||
29 | #if VERBOSE_CURL | 31 | #if VERBOSE_CURL |
30 | /** | 32 | /** |
31 | * Function to log curl debug messages with GNUNET_log | 33 | * Function to log curl debug messages with GNUNET_log |
@@ -147,6 +149,12 @@ client_send (struct Session *s, struct HTTP_Message *msg) | |||
147 | GNUNET_assert (s != NULL); | 149 | GNUNET_assert (s != NULL); |
148 | GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); | 150 | GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); |
149 | 151 | ||
152 | if (GNUNET_YES != exist_session(p, s)) | ||
153 | { | ||
154 | GNUNET_break (0); | ||
155 | return GNUNET_SYSERR; | ||
156 | } | ||
157 | |||
150 | if (s->client_put_paused == GNUNET_YES) | 158 | if (s->client_put_paused == GNUNET_YES) |
151 | { | 159 | { |
152 | #if VERBOSE_CLIENT | 160 | #if VERBOSE_CLIENT |
@@ -210,6 +218,13 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
210 | GNUNET_assert (CURLE_OK == | 218 | GNUNET_assert (CURLE_OK == |
211 | curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); | 219 | curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); |
212 | s = (struct Session *) d; | 220 | s = (struct Session *) d; |
221 | |||
222 | if (GNUNET_YES != exist_session(plugin, s)) | ||
223 | { | ||
224 | GNUNET_break (0); | ||
225 | return; | ||
226 | } | ||
227 | |||
213 | GNUNET_assert (s != NULL); | 228 | GNUNET_assert (s != NULL); |
214 | 229 | ||
215 | if (msg->msg == CURLMSG_DONE) | 230 | if (msg->msg == CURLMSG_DONE) |
@@ -241,7 +256,11 @@ client_disconnect (struct Session *s) | |||
241 | struct HTTP_Message *msg; | 256 | struct HTTP_Message *msg; |
242 | struct HTTP_Message *t; | 257 | struct HTTP_Message *t; |
243 | 258 | ||
244 | 259 | if (GNUNET_YES != exist_session(plugin, s)) | |
260 | { | ||
261 | GNUNET_break (0); | ||
262 | return GNUNET_SYSERR; | ||
263 | } | ||
245 | 264 | ||
246 | if (s->client_put != NULL) | 265 | if (s->client_put != NULL) |
247 | { | 266 | { |
@@ -319,6 +338,12 @@ client_receive_mst_cb (void *cls, void *client, | |||
319 | struct Session *s = cls; | 338 | struct Session *s = cls; |
320 | struct GNUNET_TIME_Relative delay; | 339 | struct GNUNET_TIME_Relative delay; |
321 | 340 | ||
341 | if (GNUNET_YES != exist_session(p, s)) | ||
342 | { | ||
343 | GNUNET_break (0); | ||
344 | return; | ||
345 | } | ||
346 | |||
322 | delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); | 347 | delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); |
323 | s->next_receive = | 348 | s->next_receive = |
324 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | 349 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); |
@@ -341,6 +366,12 @@ client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
341 | { | 366 | { |
342 | struct Session *s = cls; | 367 | struct Session *s = cls; |
343 | 368 | ||
369 | if (GNUNET_YES != exist_session(p, s)) | ||
370 | { | ||
371 | GNUNET_break (0); | ||
372 | return; | ||
373 | } | ||
374 | |||
344 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; | 375 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; |
345 | 376 | ||
346 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 377 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
@@ -371,6 +402,8 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
371 | size_t len = size * nmemb; | 402 | size_t len = size * nmemb; |
372 | 403 | ||
373 | 404 | ||
405 | |||
406 | |||
374 | #if VERBOSE_CLIENT | 407 | #if VERBOSE_CLIENT |
375 | struct Plugin *plugin = s->plugin; | 408 | struct Plugin *plugin = s->plugin; |
376 | 409 | ||
@@ -429,6 +462,12 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
429 | size_t bytes_sent = 0; | 462 | size_t bytes_sent = 0; |
430 | size_t len; | 463 | size_t len; |
431 | 464 | ||
465 | if (GNUNET_YES != exist_session(plugin, s)) | ||
466 | { | ||
467 | GNUNET_break (0); | ||
468 | return GNUNET_SYSERR; | ||
469 | } | ||
470 | |||
432 | struct HTTP_Message *msg = s->msg_head; | 471 | struct HTTP_Message *msg = s->msg_head; |
433 | 472 | ||
434 | if (msg == NULL) | 473 | if (msg == NULL) |
@@ -610,6 +649,7 @@ int | |||
610 | client_start (struct Plugin *plugin) | 649 | client_start (struct Plugin *plugin) |
611 | { | 650 | { |
612 | int res = GNUNET_OK; | 651 | int res = GNUNET_OK; |
652 | p = plugin; | ||
613 | 653 | ||
614 | curl_global_init (CURL_GLOBAL_ALL); | 654 | curl_global_init (CURL_GLOBAL_ALL); |
615 | plugin->client_mh = curl_multi_init (); | 655 | plugin->client_mh = curl_multi_init (); |
@@ -619,7 +659,7 @@ client_start (struct Plugin *plugin) | |||
619 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 659 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
620 | _ | 660 | _ |
621 | ("Could not initialize curl multi handle, failed to start %s plugin!\n"), | 661 | ("Could not initialize curl multi handle, failed to start %s plugin!\n"), |
622 | plugin->name); | 662 | plugin->name); |
623 | res = GNUNET_SYSERR; | 663 | res = GNUNET_SYSERR; |
624 | } | 664 | } |
625 | return res; | 665 | return res; |
@@ -628,6 +668,7 @@ client_start (struct Plugin *plugin) | |||
628 | void | 668 | void |
629 | client_stop (struct Plugin *plugin) | 669 | client_stop (struct Plugin *plugin) |
630 | { | 670 | { |
671 | p = NULL; | ||
631 | if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) | 672 | if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) |
632 | { | 673 | { |
633 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); | 674 | GNUNET_SCHEDULER_cancel (plugin->client_perform_task); |