aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-23 16:57:10 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-23 16:57:10 +0000
commitd11a7abfaf81303da7e166268200873b17caa6bc (patch)
tree9dd5c2698b4b47c0dc3afd61f34820ecfdf4b1bb /src/transport
parent5b4ec2bfc041816666e0c4f21034454d150d16e7 (diff)
downloadgnunet-d11a7abfaf81303da7e166268200873b17caa6bc.tar.gz
gnunet-d11a7abfaf81303da7e166268200873b17caa6bc.zip
-use LOG macro instead of GNUNET_log_from
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_http_client.c348
-rw-r--r--src/transport/transport-testing.c135
2 files changed, 252 insertions, 231 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 */
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index f9182b57f..b2af478e1 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -27,6 +27,9 @@
27#include "transport-testing.h" 27#include "transport-testing.h"
28 28
29 29
30#define LOG(kind,...) GNUNET_log_from(kind, "transport-testing", __VA_ARGS__)
31
32
30static struct PeerContext * 33static struct PeerContext *
31find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth, 34find_peer_context (struct GNUNET_TRANSPORT_TESTING_handle *tth,
32 const struct GNUNET_PeerIdentity *peer) 35 const struct GNUNET_PeerIdentity *peer)
@@ -82,9 +85,11 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
82 GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); 85 GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
83 else 86 else
84 GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); 87 GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
85 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 88 LOG (GNUNET_ERROR_TYPE_DEBUG,
86 "Peers %s connected to peer %u (`%s')\n", p2_s, p->no, 89 "Peers %s connected to peer %u (`%s')\n",
87 GNUNET_i2s (&p->id)); 90 p2_s,
91 p->no,
92 GNUNET_i2s (&p->id));
88 GNUNET_free (p2_s); 93 GNUNET_free (p2_s);
89 94
90 /* Find ConnectingContext */ 95 /* Find ConnectingContext */
@@ -129,9 +134,11 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
129 GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id)); 134 GNUNET_asprintf (&p2_s, "%u (`%s')", p2->no, GNUNET_i2s (&p2->id));
130 else 135 else
131 GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer)); 136 GNUNET_asprintf (&p2_s, "`%s'", GNUNET_i2s (peer));
132 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 137 LOG (GNUNET_ERROR_TYPE_DEBUG,
133 "Peers %s disconnected from peer %u (`%s')\n", p2_s, no, 138 "Peers %s disconnected from peer %u (`%s')\n",
134 GNUNET_i2s (&p->id)); 139 p2_s,
140 no,
141 GNUNET_i2s (&p->id));
135 GNUNET_free (p2_s); 142 GNUNET_free (p2_s);
136 143
137 if (p == NULL) 144 if (p == NULL)
@@ -170,9 +177,9 @@ get_hello (void *cb_cls, const struct GNUNET_MessageHeader *message)
170 177
171 if (NULL != p->start_cb) 178 if (NULL != p->start_cb)
172 { 179 {
173 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 180 LOG (GNUNET_ERROR_TYPE_DEBUG,
174 "Peer %u (`%s') successfully started\n", p->no, 181 "Peer %u (`%s') successfully started\n", p->no,
175 GNUNET_i2s (&p->id)); 182 GNUNET_i2s (&p->id));
176 p->start_cb (p, p->cb_cls); 183 p->start_cb (p, p->cb_cls);
177 p->start_cb = NULL; 184 p->start_cb = NULL;
178 } 185 }
@@ -196,10 +203,10 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
196 203
197 char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id)); 204 char *p2_s = GNUNET_strdup (GNUNET_i2s (&p2->id));
198 205
199 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 206 LOG (GNUNET_ERROR_TYPE_DEBUG,
200 "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n", 207 "Asking peer %u (`%s') to connect peer %u (`%s'), providing HELLO with %u bytes\n",
201 p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s, 208 p1->no, GNUNET_i2s (&p1->id), p2->no, p2_s,
202 GNUNET_HELLO_size (cc->p2->hello)); 209 GNUNET_HELLO_size (cc->p2->hello));
203 GNUNET_free (p2_s); 210 GNUNET_free (p2_s);
204 211
205 GNUNET_TRANSPORT_offer_hello (cc->th_p1, 212 GNUNET_TRANSPORT_offer_hello (cc->th_p1,
@@ -241,8 +248,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
241 248
242 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 249 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
243 { 250 {
244 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 251 LOG (GNUNET_ERROR_TYPE_ERROR,
245 "File not found: `%s' \n", cfgname); 252 "File not found: `%s'\n",
253 cfgname);
246 return NULL; 254 return NULL;
247 } 255 }
248 256
@@ -255,9 +263,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
255 263
256 if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg)) 264 if (GNUNET_SYSERR == GNUNET_TESTING_configuration_create (tth->tl_system, p->cfg))
257 { 265 {
258 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 266 LOG (GNUNET_ERROR_TYPE_ERROR,
259 "Testing library failed to create unique configuration based on `%s'\n", 267 "Testing library failed to create unique configuration based on `%s'\n",
260 cfgname); 268 cfgname);
261 GNUNET_free (p); 269 GNUNET_free (p);
262 return NULL; 270 return NULL;
263 } 271 }
@@ -267,9 +275,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
267 p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg); 275 p->peer = GNUNET_TESTING_peer_configure (tth->tl_system, p->cfg, p->no, NULL, &emsg);
268 if (NULL == p->peer) 276 if (NULL == p->peer)
269 { 277 {
270 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 278 LOG (GNUNET_ERROR_TYPE_ERROR,
271 "Testing library failed to create unique configuration based on `%s': `%s'\n", 279 "Testing library failed to create unique configuration based on `%s': `%s'\n",
272 cfgname, emsg); 280 cfgname,
281 emsg);
273 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 282 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
274 GNUNET_free_non_null (emsg); 283 GNUNET_free_non_null (emsg);
275 return NULL; 284 return NULL;
@@ -277,9 +286,9 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
277 GNUNET_free_non_null (emsg); 286 GNUNET_free_non_null (emsg);
278 if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer)) 287 if (GNUNET_OK != GNUNET_TESTING_peer_start (p->peer))
279 { 288 {
280 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 289 LOG (GNUNET_ERROR_TYPE_ERROR,
281 "Testing library failed to create unique configuration based on `%s'\n", 290 "Testing library failed to create unique configuration based on `%s'\n",
282 cfgname); 291 cfgname);
283 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 292 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
284 return NULL; 293 return NULL;
285 } 294 }
@@ -288,18 +297,18 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
288 GNUNET_TESTING_peer_get_identity (p->peer, &p->id); 297 GNUNET_TESTING_peer_get_identity (p->peer, &p->id);
289 if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity))) 298 if (0 == memcmp (&dummy, &p->id, sizeof (struct GNUNET_PeerIdentity)))
290 { 299 {
291 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 300 LOG (GNUNET_ERROR_TYPE_ERROR,
292 "Testing library failed to obtain peer identity for peer %u\n", 301 "Testing library failed to obtain peer identity for peer %u\n",
293 p->no); 302 p->no);
294 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 303 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
295 return NULL; 304 return NULL;
296 } 305 }
297 else 306 else
298 { 307 {
299 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 308 LOG (GNUNET_ERROR_TYPE_DEBUG,
300 "Peer %u configured with identity `%s'\n", 309 "Peer %u configured with identity `%s'\n",
301 p->no, 310 p->no,
302 GNUNET_i2s_full (&p->id)); 311 GNUNET_i2s_full (&p->id));
303 } 312 }
304 313
305 p->tth = tth; 314 p->tth = tth;
@@ -317,9 +326,10 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth
317 &notify_connect, &notify_disconnect); 326 &notify_connect, &notify_disconnect);
318 if (NULL == p->th) 327 if (NULL == p->th)
319 { 328 {
320 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 329 LOG (GNUNET_ERROR_TYPE_ERROR,
321 "Failed to connect to transport service for peer `%s': `%s'\n", 330 "Failed to connect to transport service for peer `%s': `%s'\n",
322 cfgname, emsg); 331 cfgname,
332 emsg);
323 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 333 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
324 return NULL; 334 return NULL;
325 } 335 }
@@ -350,12 +360,16 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
350 GNUNET_assert (p != NULL); 360 GNUNET_assert (p != NULL);
351 GNUNET_assert (NULL != p->peer); 361 GNUNET_assert (NULL != p->peer);
352 362
353 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 363 LOG (GNUNET_ERROR_TYPE_DEBUG,
354 "Restarting peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); 364 "Restarting peer %u (`%s')\n",
365 p->no,
366 GNUNET_i2s (&p->id));
355 367
356 /* shutdown */ 368 /* shutdown */
357 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 369 LOG (GNUNET_ERROR_TYPE_DEBUG,
358 "Stopping peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); 370 "Stopping peer %u (`%s')\n",
371 p->no,
372 GNUNET_i2s (&p->id));
359 if (NULL != p->ghh) 373 if (NULL != p->ghh)
360 GNUNET_TRANSPORT_get_hello_cancel (p->ghh); 374 GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
361 p->ghh = NULL; 375 p->ghh = NULL;
@@ -365,19 +379,21 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
365 379
366 if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer)) 380 if (GNUNET_SYSERR == GNUNET_TESTING_peer_stop(p->peer))
367 { 381 {
368 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 382 LOG (GNUNET_ERROR_TYPE_ERROR,
369 "Failed to stop peer %u (`%s')\n", p->no, GNUNET_i2s (&p->id)); 383 "Failed to stop peer %u (`%s')\n",
384 p->no,
385 GNUNET_i2s (&p->id));
370 return GNUNET_SYSERR; 386 return GNUNET_SYSERR;
371 } 387 }
372 388
373 sleep (5); 389 sleep (5); // YUCK!
374 390
375 /* restart */ 391 /* restart */
376 if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer)) 392 if (GNUNET_SYSERR == GNUNET_TESTING_peer_start(p->peer))
377 { 393 {
378 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 394 LOG (GNUNET_ERROR_TYPE_ERROR,
379 "Failed to restart peer %u (`%s')\n", 395 "Failed to restart peer %u (`%s')\n",
380 p->no, GNUNET_i2s (&p->id)); 396 p->no, GNUNET_i2s (&p->id));
381 return GNUNET_SYSERR; 397 return GNUNET_SYSERR;
382 } 398 }
383 399
@@ -423,9 +439,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
423 { 439 {
424 if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer)) 440 if (GNUNET_OK != GNUNET_TESTING_peer_stop (p->peer))
425 { 441 {
426 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 442 LOG (GNUNET_ERROR_TYPE_DEBUG,
427 "Testing lib failed to stop peer %u (`%s') \n", p->no, 443 "Testing lib failed to stop peer %u (`%s') \n", p->no,
428 GNUNET_i2s (&p->id)); 444 GNUNET_i2s (&p->id));
429 } 445 }
430 GNUNET_TESTING_peer_destroy (p->peer); 446 GNUNET_TESTING_peer_destroy (p->peer);
431 p->peer = NULL; 447 p->peer = NULL;
@@ -442,9 +458,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth,
442 p->cfg = NULL; 458 p->cfg = NULL;
443 } 459 }
444 GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p); 460 GNUNET_CONTAINER_DLL_remove (tth->p_head, tth->p_tail, p);
445 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 461 LOG (GNUNET_ERROR_TYPE_DEBUG,
446 "Peer %u (`%s') stopped \n", p->no, 462 "Peer %u (`%s') stopped \n", p->no,
447 GNUNET_i2s (&p->id)); 463 GNUNET_i2s (&p->id));
448 GNUNET_free (p); 464 GNUNET_free (p);
449} 465}
450 466
@@ -488,8 +504,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle *
488 GNUNET_assert (cc->th_p2 != NULL); 504 GNUNET_assert (cc->th_p2 != NULL);
489 GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc); 505 GNUNET_CONTAINER_DLL_insert (tth->cc_head, tth->cc_tail, cc);
490 cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); 506 cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
491 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 507 LOG (GNUNET_ERROR_TYPE_DEBUG,
492 "New connect request %p\n", cc); 508 "New connect request %p\n",
509 cc);
493 510
494 return cc; 511 return cc;
495} 512}
@@ -513,8 +530,9 @@ GNUNET_TRANSPORT_TESTING_connect_peers_cancel (struct
513 530
514 GNUNET_assert (tth != NULL); 531 GNUNET_assert (tth != NULL);
515 532
516 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 533 LOG (GNUNET_ERROR_TYPE_DEBUG,
517 "Canceling connect request %p!\n", cc); 534 "Canceling connect request %p!\n",
535 cc);
518 536
519 if (cc->tct != GNUNET_SCHEDULER_NO_TASK) 537 if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
520 GNUNET_SCHEDULER_cancel (cc->tct); 538 GNUNET_SCHEDULER_cancel (cc->tct);
@@ -542,8 +560,9 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
542 while (cc != tth->cc_tail) 560 while (cc != tth->cc_tail)
543 { 561 {
544 ct = cc->next; 562 ct = cc->next;
545 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 563 LOG (GNUNET_ERROR_TYPE_ERROR,
546 "Developer forgot to cancel connect request %p!\n", cc); 564 "Developer forgot to cancel connect request %p!\n",
565 cc);
547 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); 566 GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc);
548 cc = ct; 567 cc = ct;
549 } 568 }
@@ -551,8 +570,8 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
551 while (p != NULL) 570 while (p != NULL)
552 { 571 {
553 t = p->next; 572 t = p->next;
554 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 573 LOG (GNUNET_ERROR_TYPE_ERROR,
555 "Developer forgot to stop peer!\n"); 574 "Developer forgot to stop peer!\n");
556 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p); 575 GNUNET_TRANSPORT_TESTING_stop_peer (tth, p);
557 p = t; 576 p = t;
558 } 577 }