diff options
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 348 |
1 files changed, 175 insertions, 173 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 7da92c743..74d9f308c 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <curl/curl.h> | 51 | #include <curl/curl.h> |
52 | 52 | ||
53 | 53 | ||
54 | #define LOG(kind,...) GNUNET_log_from(kind, PLUGIN_NAME, __VA_ARGS__) | ||
54 | 55 | ||
55 | /** | 56 | /** |
56 | * Encapsulation of all of the state of the plugin. | 57 | * Encapsulation of all of the state of the plugin. |
@@ -450,13 +451,11 @@ client_log (CURL *curl, curl_infotype type, | |||
450 | text[size] = '\n'; | 451 | text[size] = '\n'; |
451 | text[size + 1] = '\0'; | 452 | text[size + 1] = '\0'; |
452 | } | 453 | } |
453 | #if BUILD_HTTPS | 454 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
454 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-https_client", | 455 | "Connection %p %s: %s", |
455 | "Connection %p %s: %s", ch->easyhandle, ttype, text); | 456 | ch->easyhandle, |
456 | #else | 457 | ttype, |
457 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-http_client", | 458 | text); |
458 | "Connection %p %s: %s", ch->easyhandle, ttype, text); | ||
459 | #endif | ||
460 | } | 459 | } |
461 | return 0; | 460 | return 0; |
462 | } | 461 | } |
@@ -509,10 +508,10 @@ http_client_plugin_send (void *cls, | |||
509 | return GNUNET_SYSERR; | 508 | return GNUNET_SYSERR; |
510 | } | 509 | } |
511 | 510 | ||
512 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 511 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
513 | "Session %p/connection %p: Sending message with %u to peer `%s' \n", | 512 | "Session %p/connection %p: Sending message with %u to peer `%s' \n", |
514 | s, s->client_put, | 513 | s, s->client_put, |
515 | msgbuf_size, GNUNET_i2s (&s->target)); | 514 | msgbuf_size, GNUNET_i2s (&s->target)); |
516 | 515 | ||
517 | /* create new message and schedule */ | 516 | /* create new message and schedule */ |
518 | msg = GNUNET_malloc (sizeof (struct HTTP_Message) + msgbuf_size); | 517 | msg = GNUNET_malloc (sizeof (struct HTTP_Message) + msgbuf_size); |
@@ -536,20 +535,21 @@ http_client_plugin_send (void *cls, | |||
536 | { | 535 | { |
537 | /* PUT connection is currently getting disconnected */ | 536 | /* PUT connection is currently getting disconnected */ |
538 | s->put_reconnect_required = GNUNET_YES; | 537 | s->put_reconnect_required = GNUNET_YES; |
539 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 538 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
540 | "Session %p/connection %jp: currently disconnecting, reconnecting immediately\n", | 539 | "Session %p/connection %jp: currently disconnecting, reconnecting immediately\n", |
541 | s, s->client_put); | 540 | s, |
541 | s->client_put); | ||
542 | return msgbuf_size; | 542 | return msgbuf_size; |
543 | } | 543 | } |
544 | else if (GNUNET_YES == s->put_paused) | 544 | if (GNUNET_YES == s->put_paused) |
545 | { | 545 | { |
546 | /* PUT connection was paused, unpause */ | 546 | /* PUT connection was paused, unpause */ |
547 | GNUNET_assert (s->put_disconnect_task != GNUNET_SCHEDULER_NO_TASK); | 547 | GNUNET_assert (s->put_disconnect_task != GNUNET_SCHEDULER_NO_TASK); |
548 | GNUNET_SCHEDULER_cancel (s->put_disconnect_task); | 548 | GNUNET_SCHEDULER_cancel (s->put_disconnect_task); |
549 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 549 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
550 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 550 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
551 | "Session %p/connection %p: unpausing connection\n", | 551 | "Session %p/connection %p: unpausing connection\n", |
552 | s, s->client_put); | 552 | s, s->client_put); |
553 | s->put_paused = GNUNET_NO; | 553 | s->put_paused = GNUNET_NO; |
554 | if (NULL != s->client_put) | 554 | if (NULL != s->client_put) |
555 | curl_easy_pause (s->client_put, CURLPAUSE_CONT); | 555 | curl_easy_pause (s->client_put, CURLPAUSE_CONT); |
@@ -557,9 +557,9 @@ http_client_plugin_send (void *cls, | |||
557 | else if (GNUNET_YES == s->put_tmp_disconnected) | 557 | else if (GNUNET_YES == s->put_tmp_disconnected) |
558 | { | 558 | { |
559 | /* PUT connection was disconnected, reconnect */ | 559 | /* PUT connection was disconnected, reconnect */ |
560 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 560 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
561 | "Session %p: Reconnecting PUT connection\n", | 561 | "Session %p: Reconnecting PUT connection\n", |
562 | s); | 562 | s); |
563 | s->put_tmp_disconnected = GNUNET_NO; | 563 | s->put_tmp_disconnected = GNUNET_NO; |
564 | GNUNET_break (s->client_put == NULL); | 564 | GNUNET_break (s->client_put == NULL); |
565 | if (GNUNET_SYSERR == client_connect_put (s)) | 565 | if (GNUNET_SYSERR == client_connect_put (s)) |
@@ -646,9 +646,9 @@ http_client_session_disconnect (void *cls, | |||
646 | 646 | ||
647 | if (NULL != s->client_put) | 647 | if (NULL != s->client_put) |
648 | { | 648 | { |
649 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 649 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
650 | "Session %p/connection %p: disconnecting PUT connection to peer `%s'\n", | 650 | "Session %p/connection %p: disconnecting PUT connection to peer `%s'\n", |
651 | s, s->client_put, GNUNET_i2s (&s->target)); | 651 | s, s->client_put, GNUNET_i2s (&s->target)); |
652 | 652 | ||
653 | /* remove curl handle from multi handle */ | 653 | /* remove curl handle from multi handle */ |
654 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, s->client_put); | 654 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, s->client_put); |
@@ -671,10 +671,10 @@ http_client_session_disconnect (void *cls, | |||
671 | 671 | ||
672 | if (NULL != s->client_get) | 672 | if (NULL != s->client_get) |
673 | { | 673 | { |
674 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 674 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
675 | "Session %p/connection %p: disconnecting GET connection to peer `%s'\n", | 675 | "Session %p/connection %p: disconnecting GET connection to peer `%s'\n", |
676 | s, s->client_get, | 676 | s, s->client_get, |
677 | GNUNET_i2s (&s->target)); | 677 | GNUNET_i2s (&s->target)); |
678 | /* remove curl handle from multi handle */ | 678 | /* remove curl handle from multi handle */ |
679 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, s->client_get); | 679 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, s->client_get); |
680 | if (mret != CURLM_OK) | 680 | if (mret != CURLM_OK) |
@@ -706,8 +706,8 @@ http_client_session_disconnect (void *cls, | |||
706 | HTTP_STAT_STR_CONNECTIONS, | 706 | HTTP_STAT_STR_CONNECTIONS, |
707 | plugin->cur_connections, | 707 | plugin->cur_connections, |
708 | GNUNET_NO); | 708 | GNUNET_NO); |
709 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 709 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
710 | "Session %p: notifying transport about ending session\n",s); | 710 | "Session %p: notifying transport about ending session\n",s); |
711 | 711 | ||
712 | plugin->env->session_end (plugin->env->cls, s->address, s); | 712 | plugin->env->session_end (plugin->env->cls, s->address, s); |
713 | client_delete_session (s); | 713 | client_delete_session (s); |
@@ -755,9 +755,9 @@ http_client_peer_disconnect (void *cls, | |||
755 | struct Session *next = NULL; | 755 | struct Session *next = NULL; |
756 | struct Session *pos = NULL; | 756 | struct Session *pos = NULL; |
757 | 757 | ||
758 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 758 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
759 | "Transport tells me to disconnect `%s'\n", | 759 | "Transport tells me to disconnect `%s'\n", |
760 | GNUNET_i2s (target)); | 760 | GNUNET_i2s (target)); |
761 | 761 | ||
762 | next = plugin->head; | 762 | next = plugin->head; |
763 | while (NULL != (pos = next)) | 763 | while (NULL != (pos = next)) |
@@ -765,9 +765,9 @@ http_client_peer_disconnect (void *cls, | |||
765 | next = pos->next; | 765 | next = pos->next; |
766 | if (0 == memcmp (target, &pos->target, sizeof (struct GNUNET_PeerIdentity))) | 766 | if (0 == memcmp (target, &pos->target, sizeof (struct GNUNET_PeerIdentity))) |
767 | { | 767 | { |
768 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 768 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
769 | "Disconnecting session %p to `%pos'\n", | 769 | "Disconnecting session %p to `%pos'\n", |
770 | pos, GNUNET_i2s (target)); | 770 | pos, GNUNET_i2s (target)); |
771 | GNUNET_assert (GNUNET_OK == http_client_session_disconnect (plugin, | 771 | GNUNET_assert (GNUNET_OK == http_client_session_disconnect (plugin, |
772 | pos)); | 772 | pos)); |
773 | } | 773 | } |
@@ -805,9 +805,9 @@ client_put_disconnect (void *cls, | |||
805 | struct Session *s = cls; | 805 | struct Session *s = cls; |
806 | 806 | ||
807 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 807 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
808 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 808 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
809 | "Session %p/connection %p: will be disconnected due to no activity\n", | 809 | "Session %p/connection %p: will be disconnected due to no activity\n", |
810 | s, s->client_put); | 810 | s, s->client_put); |
811 | s->put_paused = GNUNET_NO; | 811 | s->put_paused = GNUNET_NO; |
812 | s->put_tmp_disconnecting = GNUNET_YES; | 812 | s->put_tmp_disconnecting = GNUNET_YES; |
813 | if (NULL != s->client_put) | 813 | if (NULL != s->client_put) |
@@ -842,18 +842,17 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
842 | } | 842 | } |
843 | if (GNUNET_YES == s->put_tmp_disconnecting) | 843 | if (GNUNET_YES == s->put_tmp_disconnecting) |
844 | { | 844 | { |
845 | 845 | LOG (GNUNET_ERROR_TYPE_DEBUG, | |
846 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 846 | "Session %p/connection %p: disconnect due to inactivity\n", |
847 | "Session %p/connection %p: disconnect due to inactivity\n", | 847 | s, s->client_put); |
848 | s, s->client_put); | ||
849 | return 0; | 848 | return 0; |
850 | } | 849 | } |
851 | 850 | ||
852 | if (NULL == msg) | 851 | if (NULL == msg) |
853 | { | 852 | { |
854 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 853 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
855 | "Session %p/connection %p: nothing to send, suspending\n", | 854 | "Session %p/connection %p: nothing to send, suspending\n", |
856 | s, s->client_put); | 855 | s, s->client_put); |
857 | s->put_disconnect_task = GNUNET_SCHEDULER_add_delayed (PUT_DISCONNECT_TIMEOUT, &client_put_disconnect, s); | 856 | s->put_disconnect_task = GNUNET_SCHEDULER_add_delayed (PUT_DISCONNECT_TIMEOUT, &client_put_disconnect, s); |
858 | s->put_paused = GNUNET_YES; | 857 | s->put_paused = GNUNET_YES; |
859 | return CURL_READFUNC_PAUSE; | 858 | return CURL_READFUNC_PAUSE; |
@@ -867,9 +866,9 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) | |||
867 | msg->pos += len; | 866 | msg->pos += len; |
868 | if (msg->pos == msg->size) | 867 | if (msg->pos == msg->size) |
869 | { | 868 | { |
870 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 869 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
871 | "Session %p/connection %p: sent message with %u bytes sent, removing message from queue\n", | 870 | "Session %p/connection %p: sent message with %u bytes sent, removing message from queue\n", |
872 | s, s->client_put, msg->size, msg->pos); | 871 | s, s->client_put, msg->size, msg->pos); |
873 | /* Calling transmit continuation */ | 872 | /* Calling transmit continuation */ |
874 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); | 873 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); |
875 | if (NULL != msg->transmit_cont) | 874 | if (NULL != msg->transmit_cont) |
@@ -913,10 +912,10 @@ client_wake_up (void *cls, | |||
913 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; | 912 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; |
914 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 913 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
915 | return; | 914 | return; |
916 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 915 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
917 | "Session %p/connection %p: Waking up GET handle\n", | 916 | "Session %p/connection %p: Waking up GET handle\n", |
918 | s, | 917 | s, |
919 | s->client_get); | 918 | s->client_get); |
920 | s->put_paused = GNUNET_NO; | 919 | s->put_paused = GNUNET_NO; |
921 | if (NULL != s->client_get) | 920 | if (NULL != s->client_get) |
922 | curl_easy_pause (s->client_get, CURLPAUSE_CONT); | 921 | curl_easy_pause (s->client_get, CURLPAUSE_CONT); |
@@ -970,14 +969,14 @@ client_receive_mst_cb (void *cls, void *client, | |||
970 | 969 | ||
971 | if (GNUNET_TIME_absolute_get ().abs_value_us < s->next_receive.abs_value_us) | 970 | if (GNUNET_TIME_absolute_get ().abs_value_us < s->next_receive.abs_value_us) |
972 | { | 971 | { |
973 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 972 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
974 | "Client: peer `%s' address `%s' next read delayed for %s\n", | 973 | "Client: peer `%s' address `%s' next read delayed for %s\n", |
975 | GNUNET_i2s (&s->target), | 974 | GNUNET_i2s (&s->target), |
976 | http_common_plugin_address_to_string (NULL, | 975 | http_common_plugin_address_to_string (NULL, |
977 | s->plugin->protocol, s->address->address, | 976 | s->plugin->protocol, s->address->address, |
978 | s->address->address_length), | 977 | s->address->address_length), |
979 | GNUNET_STRINGS_relative_time_to_string (delay, | 978 | GNUNET_STRINGS_relative_time_to_string (delay, |
980 | GNUNET_YES)); | 979 | GNUNET_YES)); |
981 | } | 980 | } |
982 | client_reschedule_session_timeout (s); | 981 | client_reschedule_session_timeout (s); |
983 | return GNUNET_OK; | 982 | return GNUNET_OK; |
@@ -1018,21 +1017,21 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
1018 | struct GNUNET_TIME_Absolute now; | 1017 | struct GNUNET_TIME_Absolute now; |
1019 | size_t len = size * nmemb; | 1018 | size_t len = size * nmemb; |
1020 | 1019 | ||
1021 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 1020 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1022 | "Session %p / connection %p: Received %u bytes from peer `%s'\n", | 1021 | "Session %p / connection %p: Received %u bytes from peer `%s'\n", |
1023 | s, s->client_get, | 1022 | s, s->client_get, |
1024 | len, GNUNET_i2s (&s->target)); | 1023 | len, GNUNET_i2s (&s->target)); |
1025 | now = GNUNET_TIME_absolute_get (); | 1024 | now = GNUNET_TIME_absolute_get (); |
1026 | if (now.abs_value_us < s->next_receive.abs_value_us) | 1025 | if (now.abs_value_us < s->next_receive.abs_value_us) |
1027 | { | 1026 | { |
1028 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 1027 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
1029 | struct GNUNET_TIME_Relative delta = | 1028 | struct GNUNET_TIME_Relative delta = |
1030 | GNUNET_TIME_absolute_get_difference (now, s->next_receive); | 1029 | GNUNET_TIME_absolute_get_difference (now, s->next_receive); |
1031 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 1030 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1032 | "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", | 1031 | "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", |
1033 | s, s->client_get, | 1032 | s, s->client_get, |
1034 | GNUNET_STRINGS_relative_time_to_string (delta, | 1033 | GNUNET_STRINGS_relative_time_to_string (delta, |
1035 | GNUNET_YES)); | 1034 | GNUNET_YES)); |
1036 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) | 1035 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) |
1037 | { | 1036 | { |
1038 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); | 1037 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); |
@@ -1165,10 +1164,10 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1165 | if (easy_h == NULL) | 1164 | if (easy_h == NULL) |
1166 | { | 1165 | { |
1167 | GNUNET_break (0); | 1166 | GNUNET_break (0); |
1168 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1167 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1169 | "Client: connection to ended with reason %i: `%s', %i handles running\n", | 1168 | "Client: connection to ended with reason %i: `%s', %i handles running\n", |
1170 | msg->data.result, | 1169 | msg->data.result, |
1171 | curl_easy_strerror (msg->data.result), running); | 1170 | curl_easy_strerror (msg->data.result), running); |
1172 | continue; | 1171 | continue; |
1173 | } | 1172 | } |
1174 | 1173 | ||
@@ -1191,21 +1190,19 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1191 | { | 1190 | { |
1192 | if ((0 != msg->data.result) || (http_statuscode != 200)) | 1191 | if ((0 != msg->data.result) || (http_statuscode != 200)) |
1193 | { | 1192 | { |
1194 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1193 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1195 | plugin->name, | 1194 | "Session %p/connection %p: PUT connection to `%s' ended with status %i reason %i: `%s'\n", |
1196 | "Session %p/connection %p: PUT connection to `%s' ended with status %i reason %i: `%s'\n", | 1195 | s, msg->easy_handle, |
1197 | s, msg->easy_handle, | 1196 | GNUNET_i2s (&s->target), |
1198 | GNUNET_i2s (&s->target), | 1197 | http_statuscode, |
1199 | http_statuscode, | 1198 | msg->data.result, |
1200 | msg->data.result, | 1199 | curl_easy_strerror (msg->data.result)); |
1201 | curl_easy_strerror (msg->data.result)); | ||
1202 | } | 1200 | } |
1203 | else | 1201 | else |
1204 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1202 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1205 | plugin->name, | 1203 | "Session %p/connection %p: PUT connection to `%s' ended normal\n", |
1206 | "Session %p/connection %p: PUT connection to `%s' ended normal\n", | 1204 | s, msg->easy_handle, |
1207 | s, msg->easy_handle, | 1205 | GNUNET_i2s (&s->target)); |
1208 | GNUNET_i2s (&s->target)); | ||
1209 | if (NULL == s->client_get) | 1206 | if (NULL == s->client_get) |
1210 | { | 1207 | { |
1211 | /* Disconnect other transmission direction and tell transport */ | 1208 | /* Disconnect other transmission direction and tell transport */ |
@@ -1238,18 +1235,22 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1238 | { | 1235 | { |
1239 | if ((0 != msg->data.result) || (http_statuscode != 200)) | 1236 | if ((0 != msg->data.result) || (http_statuscode != 200)) |
1240 | { | 1237 | { |
1241 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1238 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1242 | "Session %p/connection %p: GET connection to `%s' ended with status %i reason %i: `%s'\n", | 1239 | "Session %p/connection %p: GET connection to `%s' ended with status %i reason %i: `%s'\n", |
1243 | s, msg->easy_handle, GNUNET_i2s (&s->target), | 1240 | s, |
1244 | http_statuscode, | 1241 | msg->easy_handle, |
1245 | msg->data.result, | 1242 | GNUNET_i2s (&s->target), |
1246 | curl_easy_strerror (msg->data.result)); | 1243 | http_statuscode, |
1244 | msg->data.result, | ||
1245 | curl_easy_strerror (msg->data.result)); | ||
1247 | 1246 | ||
1248 | } | 1247 | } |
1249 | else | 1248 | else |
1250 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1249 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1251 | "Session %p/connection %p: GET connection to `%s' ended normal\n", | 1250 | "Session %p/connection %p: GET connection to `%s' ended normal\n", |
1252 | s, msg->easy_handle, GNUNET_i2s (&s->target)); | 1251 | s, |
1252 | msg->easy_handle, | ||
1253 | GNUNET_i2s (&s->target)); | ||
1253 | /* Disconnect other transmission direction and tell transport */ | 1254 | /* Disconnect other transmission direction and tell transport */ |
1254 | s->get.easyhandle = NULL; | 1255 | s->get.easyhandle = NULL; |
1255 | s->get.s = NULL; | 1256 | s->get.s = NULL; |
@@ -1345,10 +1346,10 @@ client_connect_get (struct Session *s) | |||
1345 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, s->client_get); | 1346 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, s->client_get); |
1346 | if (mret != CURLM_OK) | 1347 | if (mret != CURLM_OK) |
1347 | { | 1348 | { |
1348 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, | 1349 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1349 | "Session %p : Failed to add GET handle to multihandle: `%s'\n", | 1350 | "Session %p : Failed to add GET handle to multihandle: `%s'\n", |
1350 | s, | 1351 | s, |
1351 | curl_multi_strerror (mret)); | 1352 | curl_multi_strerror (mret)); |
1352 | curl_easy_cleanup (s->client_get); | 1353 | curl_easy_cleanup (s->client_get); |
1353 | s->client_get = NULL; | 1354 | s->client_get = NULL; |
1354 | s->get.s = NULL; | 1355 | s->get.s = NULL; |
@@ -1373,8 +1374,8 @@ client_connect_put (struct Session *s) | |||
1373 | CURLMcode mret; | 1374 | CURLMcode mret; |
1374 | 1375 | ||
1375 | /* create put connection */ | 1376 | /* create put connection */ |
1376 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 1377 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1377 | "Session %p : Init PUT handle\n", s); | 1378 | "Session %p: Init PUT handle\n", s); |
1378 | s->client_put = curl_easy_init (); | 1379 | s->client_put = curl_easy_init (); |
1379 | s->put.s = s; | 1380 | s->put.s = s; |
1380 | s->put.easyhandle = s->client_put; | 1381 | s->put.easyhandle = s->client_put; |
@@ -1443,10 +1444,10 @@ client_connect_put (struct Session *s) | |||
1443 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, s->client_put); | 1444 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, s->client_put); |
1444 | if (mret != CURLM_OK) | 1445 | if (mret != CURLM_OK) |
1445 | { | 1446 | { |
1446 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, | 1447 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1447 | "Session %p : Failed to add PUT handle to multihandle: `%s'\n", | 1448 | "Session %p : Failed to add PUT handle to multihandle: `%s'\n", |
1448 | s, | 1449 | s, |
1449 | curl_multi_strerror (mret)); | 1450 | curl_multi_strerror (mret)); |
1450 | curl_easy_cleanup (s->client_put); | 1451 | curl_easy_cleanup (s->client_put); |
1451 | s->client_put = NULL; | 1452 | s->client_put = NULL; |
1452 | s->put.easyhandle = NULL; | 1453 | s->put.easyhandle = NULL; |
@@ -1476,10 +1477,9 @@ client_connect (struct Session *s) | |||
1476 | if (NULL == http_common_plugin_address_to_string (NULL, | 1477 | if (NULL == http_common_plugin_address_to_string (NULL, |
1477 | plugin->protocol, s->address->address, s->address->address_length)) | 1478 | plugin->protocol, s->address->address, s->address->address_length)) |
1478 | { | 1479 | { |
1479 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1480 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1480 | plugin->name, | 1481 | "Invalid address peer `%s'\n", |
1481 | "Invalid address peer `%s'\n", | 1482 | GNUNET_i2s (&s->target)); |
1482 | GNUNET_i2s (&s->target)); | ||
1483 | return GNUNET_SYSERR; | 1483 | return GNUNET_SYSERR; |
1484 | } | 1484 | } |
1485 | 1485 | ||
@@ -1490,10 +1490,9 @@ client_connect (struct Session *s) | |||
1490 | plugin->last_tag); | 1490 | plugin->last_tag); |
1491 | 1491 | ||
1492 | plugin->last_tag++; | 1492 | plugin->last_tag++; |
1493 | 1493 | LOG (GNUNET_ERROR_TYPE_DEBUG, | |
1494 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1494 | "Initiating outbound session peer `%s' using address `%s'\n", |
1495 | "Initiating outbound session peer `%s' using address `%s'\n", | 1495 | GNUNET_i2s (&s->target), s->url); |
1496 | GNUNET_i2s (&s->target), s->url); | ||
1497 | 1496 | ||
1498 | if ((GNUNET_SYSERR == client_connect_get (s)) || | 1497 | if ((GNUNET_SYSERR == client_connect_get (s)) || |
1499 | (GNUNET_SYSERR == client_connect_put (s))) | 1498 | (GNUNET_SYSERR == client_connect_put (s))) |
@@ -1503,11 +1502,11 @@ client_connect (struct Session *s) | |||
1503 | return GNUNET_SYSERR; | 1502 | return GNUNET_SYSERR; |
1504 | } | 1503 | } |
1505 | 1504 | ||
1506 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 1505 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1507 | plugin->name, | 1506 | "Session %p: connected with connections GET %p and PUT %p\n", |
1508 | "Session %p: connected with connections GET %p and PUT %p\n", | 1507 | s, |
1509 | s, s->client_get, s->client_put); | 1508 | s->client_get, |
1510 | 1509 | s->client_put); | |
1511 | /* Perform connect */ | 1510 | /* Perform connect */ |
1512 | plugin->cur_connections += 2; | 1511 | plugin->cur_connections += 2; |
1513 | GNUNET_STATISTICS_set (plugin->env->stats, | 1512 | GNUNET_STATISTICS_set (plugin->env->stats, |
@@ -1554,11 +1553,11 @@ client_session_timeout (void *cls, | |||
1554 | struct Session *s = cls; | 1553 | struct Session *s = cls; |
1555 | 1554 | ||
1556 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 1555 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
1557 | GNUNET_log (TIMEOUT_LOG, | 1556 | LOG (TIMEOUT_LOG, |
1558 | "Session %p was idle for %s, disconnecting\n", | 1557 | "Session %p was idle for %s, disconnecting\n", |
1559 | s, | 1558 | s, |
1560 | GNUNET_STRINGS_relative_time_to_string (HTTP_CLIENT_SESSION_TIMEOUT, | 1559 | GNUNET_STRINGS_relative_time_to_string (HTTP_CLIENT_SESSION_TIMEOUT, |
1561 | GNUNET_YES)); | 1560 | GNUNET_YES)); |
1562 | 1561 | ||
1563 | /* call session destroy function */ | 1562 | /* call session destroy function */ |
1564 | GNUNET_assert (GNUNET_OK == http_client_session_disconnect (s->plugin, | 1563 | GNUNET_assert (GNUNET_OK == http_client_session_disconnect (s->plugin, |
@@ -1594,11 +1593,11 @@ http_client_plugin_get_session (void *cls, | |||
1594 | 1593 | ||
1595 | if (plugin->max_connections <= plugin->cur_connections) | 1594 | if (plugin->max_connections <= plugin->cur_connections) |
1596 | { | 1595 | { |
1597 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, | 1596 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1598 | "Maximum number of connections (%u) reached: " | 1597 | "Maximum number of connections (%u) reached: " |
1599 | "cannot connect to peer `%s'\n", | 1598 | "cannot connect to peer `%s'\n", |
1600 | plugin->max_connections, | 1599 | plugin->max_connections, |
1601 | GNUNET_i2s (&address->peer)); | 1600 | GNUNET_i2s (&address->peer)); |
1602 | return NULL; | 1601 | return NULL; |
1603 | } | 1602 | } |
1604 | 1603 | ||
@@ -1647,12 +1646,12 @@ http_client_plugin_get_session (void *cls, | |||
1647 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (HTTP_CLIENT_SESSION_TIMEOUT, | 1646 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (HTTP_CLIENT_SESSION_TIMEOUT, |
1648 | &client_session_timeout, | 1647 | &client_session_timeout, |
1649 | s); | 1648 | s); |
1650 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1649 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1651 | "Created new session %p for `%s' address `%s''\n", | 1650 | "Created new session %p for `%s' address `%s''\n", |
1652 | s, http_common_plugin_address_to_string (NULL, | 1651 | s, http_common_plugin_address_to_string (NULL, |
1653 | plugin->protocol, s->address->address, | 1652 | plugin->protocol, s->address->address, |
1654 | s->address->address_length), | 1653 | s->address->address_length), |
1655 | GNUNET_i2s (&s->target)); | 1654 | GNUNET_i2s (&s->target)); |
1656 | 1655 | ||
1657 | /* add new session */ | 1656 | /* add new session */ |
1658 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); | 1657 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); |
@@ -1660,12 +1659,12 @@ http_client_plugin_get_session (void *cls, | |||
1660 | /* initiate new connection */ | 1659 | /* initiate new connection */ |
1661 | if (GNUNET_SYSERR == client_connect (s)) | 1660 | if (GNUNET_SYSERR == client_connect (s)) |
1662 | { | 1661 | { |
1663 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1662 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1664 | "Cannot connect to peer `%s' address `%s''\n", | 1663 | "Cannot connect to peer `%s' address `%s''\n", |
1665 | http_common_plugin_address_to_string (NULL, | 1664 | http_common_plugin_address_to_string (NULL, |
1666 | plugin->protocol, s->address->address, | 1665 | plugin->protocol, s->address->address, |
1667 | s->address->address_length), | 1666 | s->address->address_length), |
1668 | GNUNET_i2s (&s->target)); | 1667 | GNUNET_i2s (&s->target)); |
1669 | client_delete_session (s); | 1668 | client_delete_session (s); |
1670 | return NULL; | 1669 | return NULL; |
1671 | } | 1670 | } |
@@ -1687,9 +1686,9 @@ client_start (struct HTTP_Client_Plugin *plugin) | |||
1687 | 1686 | ||
1688 | if (NULL == plugin->curl_multi_handle) | 1687 | if (NULL == plugin->curl_multi_handle) |
1689 | { | 1688 | { |
1690 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1689 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1691 | _("Could not initialize curl multi handle, failed to start %s plugin!\n"), | 1690 | _("Could not initialize curl multi handle, failed to start %s plugin!\n"), |
1692 | plugin->name); | 1691 | plugin->name); |
1693 | return GNUNET_SYSERR; | 1692 | return GNUNET_SYSERR; |
1694 | } | 1693 | } |
1695 | return GNUNET_OK; | 1694 | return GNUNET_OK; |
@@ -1709,11 +1708,11 @@ client_reschedule_session_timeout (struct Session *s) | |||
1709 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (HTTP_CLIENT_SESSION_TIMEOUT, | 1708 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (HTTP_CLIENT_SESSION_TIMEOUT, |
1710 | &client_session_timeout, | 1709 | &client_session_timeout, |
1711 | s); | 1710 | s); |
1712 | GNUNET_log (TIMEOUT_LOG, | 1711 | LOG (TIMEOUT_LOG, |
1713 | "Timeout rescheduled for session %p set to %s\n", | 1712 | "Timeout rescheduled for session %p set to %s\n", |
1714 | s, | 1713 | s, |
1715 | GNUNET_STRINGS_relative_time_to_string (HTTP_CLIENT_SESSION_TIMEOUT, | 1714 | GNUNET_STRINGS_relative_time_to_string (HTTP_CLIENT_SESSION_TIMEOUT, |
1716 | GNUNET_YES)); | 1715 | GNUNET_YES)); |
1717 | } | 1716 | } |
1718 | 1717 | ||
1719 | 1718 | ||
@@ -1762,10 +1761,9 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
1762 | return NULL; | 1761 | return NULL; |
1763 | } | 1762 | } |
1764 | 1763 | ||
1765 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1764 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1766 | _("Shutting down plugin `%s'\n"), | 1765 | _("Shutting down plugin `%s'\n"), |
1767 | plugin->name); | 1766 | plugin->name); |
1768 | |||
1769 | 1767 | ||
1770 | next = plugin->head; | 1768 | next = plugin->head; |
1771 | while (NULL != (pos = next)) | 1769 | while (NULL != (pos = next)) |
@@ -1787,9 +1785,9 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
1787 | } | 1785 | } |
1788 | curl_global_cleanup (); | 1786 | curl_global_cleanup (); |
1789 | 1787 | ||
1790 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1788 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1791 | _("Shutdown for plugin `%s' complete\n"), | 1789 | _("Shutdown for plugin `%s' complete\n"), |
1792 | plugin->name); | 1790 | plugin->name); |
1793 | 1791 | ||
1794 | GNUNET_free_non_null (plugin->proxy_hostname); | 1792 | GNUNET_free_non_null (plugin->proxy_hostname); |
1795 | GNUNET_free_non_null (plugin->proxy_username); | 1793 | GNUNET_free_non_null (plugin->proxy_username); |
@@ -1821,33 +1819,36 @@ client_configure_plugin (struct HTTP_Client_Plugin *plugin) | |||
1821 | max_connections = 128; | 1819 | max_connections = 128; |
1822 | plugin->max_connections = max_connections; | 1820 | plugin->max_connections = max_connections; |
1823 | 1821 | ||
1824 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1822 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1825 | _("Maximum number of connections is %u\n"), | 1823 | _("Maximum number of connections is %u\n"), |
1826 | plugin->max_connections); | 1824 | plugin->max_connections); |
1827 | 1825 | ||
1828 | /* Read proxy configuration */ | 1826 | /* Read proxy configuration */ |
1829 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, | 1827 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, |
1830 | plugin->name, "PROXY", &plugin->proxy_hostname)) | 1828 | plugin->name, "PROXY", &plugin->proxy_hostname)) |
1831 | { | 1829 | { |
1832 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1830 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1833 | "Found proxy host: `%s'\n", | 1831 | "Found proxy host: `%s'\n", |
1834 | plugin->proxy_hostname); | 1832 | plugin->proxy_hostname); |
1835 | /* proxy username */ | 1833 | /* proxy username */ |
1836 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, | 1834 | if (GNUNET_OK == |
1837 | plugin->name, "PROXY_USERNAME", &plugin->proxy_username)) | 1835 | GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, |
1836 | plugin->name, | ||
1837 | "PROXY_USERNAME", | ||
1838 | &plugin->proxy_username)) | ||
1838 | { | 1839 | { |
1839 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1840 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1840 | "Found proxy username name: `%s'\n", | 1841 | "Found proxy username name: `%s'\n", |
1841 | plugin->proxy_username); | 1842 | plugin->proxy_username); |
1842 | } | 1843 | } |
1843 | 1844 | ||
1844 | /* proxy password */ | 1845 | /* proxy password */ |
1845 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, | 1846 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, |
1846 | plugin->name, "PROXY_PASSWORD", &plugin->proxy_password)) | 1847 | plugin->name, "PROXY_PASSWORD", &plugin->proxy_password)) |
1847 | { | 1848 | { |
1848 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1849 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1849 | "Found proxy password name: `%s'\n", | 1850 | "Found proxy password name: `%s'\n", |
1850 | plugin->proxy_password); | 1851 | plugin->proxy_password); |
1851 | } | 1852 | } |
1852 | 1853 | ||
1853 | /* proxy type */ | 1854 | /* proxy type */ |
@@ -1868,7 +1869,7 @@ client_configure_plugin (struct HTTP_Client_Plugin *plugin) | |||
1868 | plugin->proxytype = CURLPROXY_SOCKS5_HOSTNAME ; | 1869 | plugin->proxytype = CURLPROXY_SOCKS5_HOSTNAME ; |
1869 | else | 1870 | else |
1870 | { | 1871 | { |
1871 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1872 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1872 | _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"), | 1873 | _("Invalid proxy type: `%s', disabling proxy! Check configuration!\n"), |
1873 | proxy_type); | 1874 | proxy_type); |
1874 | 1875 | ||
@@ -1883,8 +1884,9 @@ client_configure_plugin (struct HTTP_Client_Plugin *plugin) | |||
1883 | return GNUNET_SYSERR; | 1884 | return GNUNET_SYSERR; |
1884 | } | 1885 | } |
1885 | 1886 | ||
1886 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1887 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1887 | "Found proxy type: `%s'\n", proxy_type); | 1888 | "Found proxy type: `%s'\n", |
1889 | proxy_type); | ||
1888 | } | 1890 | } |
1889 | 1891 | ||
1890 | /* proxy http tunneling */ | 1892 | /* proxy http tunneling */ |