diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-06-26 20:01:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-06-26 20:01:53 +0000 |
commit | f5c4fff8b1ae75229860031921ef3faaf88b80dc (patch) | |
tree | 96e2162bb29d817d85348135ac118673c7d2c8f0 /src/transport | |
parent | c9c6be8fddd92d768eebfc871c639ec987abbc40 (diff) | |
download | gnunet-f5c4fff8b1ae75229860031921ef3faaf88b80dc.tar.gz gnunet-f5c4fff8b1ae75229860031921ef3faaf88b80dc.zip |
removing duplicate curl handles
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 224 |
1 files changed, 102 insertions, 122 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 7a50ebd38..073129551 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -150,23 +150,11 @@ struct Session | |||
150 | struct HTTP_Client_Plugin *plugin; | 150 | struct HTTP_Client_Plugin *plugin; |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * Curl client PUT handle. | ||
154 | * FIXME: delta to put.easyhandle? | ||
155 | */ | ||
156 | CURL *client_put; | ||
157 | |||
158 | /** | ||
159 | * Handle for the HTTP PUT request. | 153 | * Handle for the HTTP PUT request. |
160 | */ | 154 | */ |
161 | struct ConnectionHandle put; | 155 | struct ConnectionHandle put; |
162 | 156 | ||
163 | /** | 157 | /** |
164 | * Curl client GET handle | ||
165 | * FIXME: delta to get.easyhandle? | ||
166 | */ | ||
167 | CURL *client_get; | ||
168 | |||
169 | /** | ||
170 | * Handle for the HTTP GET request. | 158 | * Handle for the HTTP GET request. |
171 | */ | 159 | */ |
172 | struct ConnectionHandle get; | 160 | struct ConnectionHandle get; |
@@ -433,35 +421,35 @@ client_delete_session (struct Session *s) | |||
433 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, | 421 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, |
434 | &s->address->peer, | 422 | &s->address->peer, |
435 | s)); | 423 | s)); |
436 | if (NULL != s->client_put) | 424 | if (NULL != s->put.easyhandle) |
437 | { | 425 | { |
438 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 426 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
439 | "Session %p/connection %p: disconnecting PUT connection to peer `%s'\n", | 427 | "Session %p/connection %p: disconnecting PUT connection to peer `%s'\n", |
440 | s, | 428 | s, |
441 | s->client_put, | 429 | s->put.easyhandle, |
442 | GNUNET_i2s (&s->address->peer)); | 430 | GNUNET_i2s (&s->address->peer)); |
443 | 431 | ||
444 | /* remove curl handle from multi handle */ | 432 | /* remove curl handle from multi handle */ |
445 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, | 433 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, |
446 | s->client_put); | 434 | s->put.easyhandle); |
447 | GNUNET_break (CURLM_OK == mret); | 435 | GNUNET_break (CURLM_OK == mret); |
448 | curl_easy_cleanup (s->client_put); | 436 | curl_easy_cleanup (s->put.easyhandle); |
449 | s->client_put = NULL; | 437 | s->put.easyhandle = NULL; |
450 | } | 438 | } |
451 | if (NULL != s->client_get) | 439 | if (NULL != s->get.easyhandle) |
452 | { | 440 | { |
453 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 441 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
454 | "Session %p/connection %p: disconnecting GET connection to peer `%s'\n", | 442 | "Session %p/connection %p: disconnecting GET connection to peer `%s'\n", |
455 | s, s->client_get, | 443 | s, s->get.easyhandle, |
456 | GNUNET_i2s (&s->address->peer)); | 444 | GNUNET_i2s (&s->address->peer)); |
457 | /* remove curl handle from multi handle */ | 445 | /* remove curl handle from multi handle */ |
458 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, | 446 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, |
459 | s->client_get); | 447 | s->get.easyhandle); |
460 | GNUNET_break (CURLM_OK == mret); | 448 | GNUNET_break (CURLM_OK == mret); |
461 | curl_easy_cleanup (s->client_get); | 449 | curl_easy_cleanup (s->get.easyhandle); |
462 | GNUNET_assert (plugin->cur_connections > 0); | 450 | GNUNET_assert (plugin->cur_connections > 0); |
463 | plugin->cur_connections--; | 451 | plugin->cur_connections--; |
464 | s->client_get = NULL; | 452 | s->get.easyhandle = NULL; |
465 | } | 453 | } |
466 | GNUNET_STATISTICS_set (plugin->env->stats, | 454 | GNUNET_STATISTICS_set (plugin->env->stats, |
467 | HTTP_STAT_STR_CONNECTIONS, | 455 | HTTP_STAT_STR_CONNECTIONS, |
@@ -713,7 +701,7 @@ http_client_plugin_send (void *cls, | |||
713 | 701 | ||
714 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 702 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
715 | "Session %p/connection %p: Sending message with %u to peer `%s' \n", | 703 | "Session %p/connection %p: Sending message with %u to peer `%s' \n", |
716 | s, s->client_put, | 704 | s, s->put.easyhandle, |
717 | msgbuf_size, GNUNET_i2s (&s->address->peer)); | 705 | msgbuf_size, GNUNET_i2s (&s->address->peer)); |
718 | 706 | ||
719 | /* create new message and schedule */ | 707 | /* create new message and schedule */ |
@@ -747,7 +735,7 @@ http_client_plugin_send (void *cls, | |||
747 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 735 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
748 | "Session %p/connection %jp: currently disconnecting, reconnecting immediately\n", | 736 | "Session %p/connection %jp: currently disconnecting, reconnecting immediately\n", |
749 | s, | 737 | s, |
750 | s->client_put); | 738 | s->put.easyhandle); |
751 | return msgbuf_size; | 739 | return msgbuf_size; |
752 | } | 740 | } |
753 | if (GNUNET_YES == s->put_paused) | 741 | if (GNUNET_YES == s->put_paused) |
@@ -758,10 +746,10 @@ http_client_plugin_send (void *cls, | |||
758 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 746 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
759 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 747 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
760 | "Session %p/connection %p: unpausing connection\n", | 748 | "Session %p/connection %p: unpausing connection\n", |
761 | s, s->client_put); | 749 | s, s->put.easyhandle); |
762 | s->put_paused = GNUNET_NO; | 750 | s->put_paused = GNUNET_NO; |
763 | if (NULL != s->client_put) | 751 | if (NULL != s->put.easyhandle) |
764 | curl_easy_pause (s->client_put, CURLPAUSE_CONT); | 752 | curl_easy_pause (s->put.easyhandle, CURLPAUSE_CONT); |
765 | } | 753 | } |
766 | else if (GNUNET_YES == s->put_tmp_disconnected) | 754 | else if (GNUNET_YES == s->put_tmp_disconnected) |
767 | { | 755 | { |
@@ -770,7 +758,7 @@ http_client_plugin_send (void *cls, | |||
770 | "Session %p: Reconnecting PUT connection\n", | 758 | "Session %p: Reconnecting PUT connection\n", |
771 | s); | 759 | s); |
772 | s->put_tmp_disconnected = GNUNET_NO; | 760 | s->put_tmp_disconnected = GNUNET_NO; |
773 | GNUNET_break (NULL == s->client_put); | 761 | GNUNET_break (NULL == s->put.easyhandle); |
774 | if (GNUNET_SYSERR == client_connect_put (s)) | 762 | if (GNUNET_SYSERR == client_connect_put (s)) |
775 | return GNUNET_SYSERR; | 763 | return GNUNET_SYSERR; |
776 | } | 764 | } |
@@ -954,13 +942,11 @@ client_put_disconnect (void *cls, | |||
954 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 942 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
955 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 943 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
956 | "Session %p/connection %p: will be disconnected due to no activity\n", | 944 | "Session %p/connection %p: will be disconnected due to no activity\n", |
957 | s, | 945 | s, s->put.easyhandle); |
958 | s->client_put); | ||
959 | s->put_paused = GNUNET_NO; | 946 | s->put_paused = GNUNET_NO; |
960 | s->put_tmp_disconnecting = GNUNET_YES; | 947 | s->put_tmp_disconnecting = GNUNET_YES; |
961 | if (NULL != s->client_put) | 948 | if (NULL != s->put.easyhandle) |
962 | curl_easy_pause (s->client_put, | 949 | curl_easy_pause (s->put.easyhandle, CURLPAUSE_CONT); |
963 | CURLPAUSE_CONT); | ||
964 | client_schedule (s->plugin, GNUNET_YES); | 950 | client_schedule (s->plugin, GNUNET_YES); |
965 | } | 951 | } |
966 | 952 | ||
@@ -991,8 +977,7 @@ client_send_cb (void *stream, | |||
991 | { | 977 | { |
992 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 978 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
993 | "Session %p/connection %p: disconnect due to inactivity\n", | 979 | "Session %p/connection %p: disconnect due to inactivity\n", |
994 | s, | 980 | s, s->put.easyhandle); |
995 | s->client_put); | ||
996 | return 0; | 981 | return 0; |
997 | } | 982 | } |
998 | 983 | ||
@@ -1000,7 +985,7 @@ client_send_cb (void *stream, | |||
1000 | { | 985 | { |
1001 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 986 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1002 | "Session %p/connection %p: nothing to send, suspending\n", | 987 | "Session %p/connection %p: nothing to send, suspending\n", |
1003 | s, s->client_put); | 988 | s, s->put.easyhandle); |
1004 | s->put_disconnect_task = GNUNET_SCHEDULER_add_delayed (PUT_DISCONNECT_TIMEOUT, | 989 | s->put_disconnect_task = GNUNET_SCHEDULER_add_delayed (PUT_DISCONNECT_TIMEOUT, |
1005 | &client_put_disconnect, | 990 | &client_put_disconnect, |
1006 | s); | 991 | s); |
@@ -1018,7 +1003,7 @@ client_send_cb (void *stream, | |||
1018 | { | 1003 | { |
1019 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1004 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1020 | "Session %p/connection %p: sent message with %u bytes sent, removing message from queue\n", | 1005 | "Session %p/connection %p: sent message with %u bytes sent, removing message from queue\n", |
1021 | s, s->client_put, msg->size, msg->pos); | 1006 | s, s->put.easyhandle, msg->size, msg->pos); |
1022 | /* Calling transmit continuation */ | 1007 | /* Calling transmit continuation */ |
1023 | GNUNET_CONTAINER_DLL_remove (s->msg_head, | 1008 | GNUNET_CONTAINER_DLL_remove (s->msg_head, |
1024 | s->msg_tail, | 1009 | s->msg_tail, |
@@ -1076,8 +1061,7 @@ client_wake_up (void *cls, | |||
1076 | return; | 1061 | return; |
1077 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1062 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1078 | "Session %p/connection %p: Waking up GET handle\n", | 1063 | "Session %p/connection %p: Waking up GET handle\n", |
1079 | s, | 1064 | s, s->get.easyhandle); |
1080 | s->client_get); | ||
1081 | if (GNUNET_YES == s->put_paused) | 1065 | if (GNUNET_YES == s->put_paused) |
1082 | { | 1066 | { |
1083 | /* PUT connection was paused, unpause */ | 1067 | /* PUT connection was paused, unpause */ |
@@ -1085,11 +1069,11 @@ client_wake_up (void *cls, | |||
1085 | GNUNET_SCHEDULER_cancel (s->put_disconnect_task); | 1069 | GNUNET_SCHEDULER_cancel (s->put_disconnect_task); |
1086 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 1070 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
1087 | s->put_paused = GNUNET_NO; | 1071 | s->put_paused = GNUNET_NO; |
1088 | if (NULL != s->client_put) | 1072 | if (NULL != s->put.easyhandle) |
1089 | curl_easy_pause (s->client_put, CURLPAUSE_CONT); | 1073 | curl_easy_pause (s->put.easyhandle, CURLPAUSE_CONT); |
1090 | } | 1074 | } |
1091 | if (NULL != s->client_get) | 1075 | if (NULL != s->get.easyhandle) |
1092 | curl_easy_pause (s->client_get, | 1076 | curl_easy_pause (s->get.easyhandle, |
1093 | CURLPAUSE_CONT); | 1077 | CURLPAUSE_CONT); |
1094 | } | 1078 | } |
1095 | 1079 | ||
@@ -1194,7 +1178,7 @@ client_receive (void *stream, | |||
1194 | 1178 | ||
1195 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1179 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1196 | "Session %p / connection %p: Received %u bytes from peer `%s'\n", | 1180 | "Session %p / connection %p: Received %u bytes from peer `%s'\n", |
1197 | s, s->client_get, | 1181 | s, s->get.easyhandle, |
1198 | len, GNUNET_i2s (&s->address->peer)); | 1182 | len, GNUNET_i2s (&s->address->peer)); |
1199 | now = GNUNET_TIME_absolute_get (); | 1183 | now = GNUNET_TIME_absolute_get (); |
1200 | if (now.abs_value_us < s->next_receive.abs_value_us) | 1184 | if (now.abs_value_us < s->next_receive.abs_value_us) |
@@ -1206,7 +1190,7 @@ client_receive (void *stream, | |||
1206 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1190 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1207 | "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", | 1191 | "Session %p / connection %p: No inbound bandwidth available! Next read was delayed for %s\n", |
1208 | s, | 1192 | s, |
1209 | s->client_get, | 1193 | s->get.easyhandle, |
1210 | GNUNET_STRINGS_relative_time_to_string (delta, | 1194 | GNUNET_STRINGS_relative_time_to_string (delta, |
1211 | GNUNET_YES)); | 1195 | GNUNET_YES)); |
1212 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) | 1196 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -1285,7 +1269,7 @@ client_run (void *cls, | |||
1285 | curl_easy_getinfo (easy_h, | 1269 | curl_easy_getinfo (easy_h, |
1286 | CURLINFO_RESPONSE_CODE, | 1270 | CURLINFO_RESPONSE_CODE, |
1287 | &http_statuscode)); | 1271 | &http_statuscode)); |
1288 | if (easy_h == s->client_put) | 1272 | if (easy_h == s->put.easyhandle) |
1289 | { | 1273 | { |
1290 | if ((0 != msg->data.result) || (http_statuscode != 200)) | 1274 | if ((0 != msg->data.result) || (http_statuscode != 200)) |
1291 | { | 1275 | { |
@@ -1302,7 +1286,7 @@ curl_easy_getinfo (easy_h, | |||
1302 | "Session %p/connection %p: PUT connection to `%s' ended normal\n", | 1286 | "Session %p/connection %p: PUT connection to `%s' ended normal\n", |
1303 | s, msg->easy_handle, | 1287 | s, msg->easy_handle, |
1304 | GNUNET_i2s (&s->address->peer)); | 1288 | GNUNET_i2s (&s->address->peer)); |
1305 | if (NULL == s->client_get) | 1289 | if (NULL == s->get.easyhandle) |
1306 | { | 1290 | { |
1307 | /* Disconnect other transmission direction and tell transport */ | 1291 | /* Disconnect other transmission direction and tell transport */ |
1308 | /* FIXME? */ | 1292 | /* FIXME? */ |
@@ -1314,7 +1298,7 @@ curl_easy_getinfo (easy_h, | |||
1314 | plugin->cur_connections--; | 1298 | plugin->cur_connections--; |
1315 | s->put_tmp_disconnecting = GNUNET_NO; | 1299 | s->put_tmp_disconnecting = GNUNET_NO; |
1316 | s->put_tmp_disconnected = GNUNET_YES; | 1300 | s->put_tmp_disconnected = GNUNET_YES; |
1317 | s->client_put = NULL; | 1301 | s->put.easyhandle = NULL; |
1318 | s->put.easyhandle = NULL; | 1302 | s->put.easyhandle = NULL; |
1319 | s->put.s = NULL; | 1303 | s->put.s = NULL; |
1320 | 1304 | ||
@@ -1328,12 +1312,12 @@ curl_easy_getinfo (easy_h, | |||
1328 | s->put_reconnect_required = GNUNET_NO; | 1312 | s->put_reconnect_required = GNUNET_NO; |
1329 | if (GNUNET_SYSERR == client_connect_put (s)) | 1313 | if (GNUNET_SYSERR == client_connect_put (s)) |
1330 | { | 1314 | { |
1331 | GNUNET_break (s->client_put == NULL); | 1315 | GNUNET_break (s->put.easyhandle == NULL); |
1332 | GNUNET_break (s->put_tmp_disconnected == GNUNET_NO); | 1316 | GNUNET_break (s->put_tmp_disconnected == GNUNET_NO); |
1333 | } | 1317 | } |
1334 | } | 1318 | } |
1335 | } | 1319 | } |
1336 | if (easy_h == s->client_get) | 1320 | if (easy_h == s->get.easyhandle) |
1337 | { | 1321 | { |
1338 | if ((0 != msg->data.result) || (http_statuscode != 200)) | 1322 | if ((0 != msg->data.result) || (http_statuscode != 200)) |
1339 | { | 1323 | { |
@@ -1381,16 +1365,15 @@ client_connect_get (struct Session *s) | |||
1381 | CURLMcode mret; | 1365 | CURLMcode mret; |
1382 | 1366 | ||
1383 | /* create get connection */ | 1367 | /* create get connection */ |
1384 | s->client_get = curl_easy_init (); | 1368 | s->get.easyhandle = curl_easy_init (); |
1385 | s->get.s = s; | 1369 | s->get.s = s; |
1386 | s->get.easyhandle = s->client_get; | ||
1387 | #if VERBOSE_CURL | 1370 | #if VERBOSE_CURL |
1388 | curl_easy_setopt (s->client_get, CURLOPT_VERBOSE, 1L); | 1371 | curl_easy_setopt (s->get.easyhandle, CURLOPT_VERBOSE, 1L); |
1389 | curl_easy_setopt (s->client_get, CURLOPT_DEBUGFUNCTION, &client_log); | 1372 | curl_easy_setopt (s->get.easyhandle, CURLOPT_DEBUGFUNCTION, &client_log); |
1390 | curl_easy_setopt (s->client_get, CURLOPT_DEBUGDATA, &s->get); | 1373 | curl_easy_setopt (s->get.easyhandle, CURLOPT_DEBUGDATA, &s->get); |
1391 | #endif | 1374 | #endif |
1392 | #if BUILD_HTTPS | 1375 | #if BUILD_HTTPS |
1393 | curl_easy_setopt (s->client_get, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); | 1376 | curl_easy_setopt (s->get.easyhandle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); |
1394 | { | 1377 | { |
1395 | struct HttpAddress *ha; | 1378 | struct HttpAddress *ha; |
1396 | 1379 | ||
@@ -1399,66 +1382,66 @@ client_connect_get (struct Session *s) | |||
1399 | if (HTTP_OPTIONS_VERIFY_CERTIFICATE == | 1382 | if (HTTP_OPTIONS_VERIFY_CERTIFICATE == |
1400 | (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE)) | 1383 | (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE)) |
1401 | { | 1384 | { |
1402 | curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1L); | 1385 | curl_easy_setopt (s->get.easyhandle, CURLOPT_SSL_VERIFYPEER, 1L); |
1403 | curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 2L); | 1386 | curl_easy_setopt (s->get.easyhandle, CURLOPT_SSL_VERIFYHOST, 2L); |
1404 | } | 1387 | } |
1405 | else | 1388 | else |
1406 | { | 1389 | { |
1407 | curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 0); | 1390 | curl_easy_setopt (s->get.easyhandle, CURLOPT_SSL_VERIFYPEER, 0); |
1408 | curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 0); | 1391 | curl_easy_setopt (s->get.easyhandle, CURLOPT_SSL_VERIFYHOST, 0); |
1409 | } | 1392 | } |
1410 | } | 1393 | } |
1411 | curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); | 1394 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); |
1412 | curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); | 1395 | curl_easy_setopt (s->get.easyhandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); |
1413 | #else | 1396 | #else |
1414 | curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); | 1397 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); |
1415 | curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); | 1398 | curl_easy_setopt (s->get.easyhandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); |
1416 | #endif | 1399 | #endif |
1417 | 1400 | ||
1418 | if (NULL != s->plugin->proxy_hostname) | 1401 | if (NULL != s->plugin->proxy_hostname) |
1419 | { | 1402 | { |
1420 | curl_easy_setopt (s->client_get, CURLOPT_PROXY, s->plugin->proxy_hostname); | 1403 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PROXY, s->plugin->proxy_hostname); |
1421 | curl_easy_setopt (s->client_get, CURLOPT_PROXYTYPE, s->plugin->proxytype); | 1404 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PROXYTYPE, s->plugin->proxytype); |
1422 | if (NULL != s->plugin->proxy_username) | 1405 | if (NULL != s->plugin->proxy_username) |
1423 | curl_easy_setopt (s->client_get, CURLOPT_PROXYUSERNAME, | 1406 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PROXYUSERNAME, |
1424 | s->plugin->proxy_username); | 1407 | s->plugin->proxy_username); |
1425 | if (NULL != s->plugin->proxy_password) | 1408 | if (NULL != s->plugin->proxy_password) |
1426 | curl_easy_setopt (s->client_get, CURLOPT_PROXYPASSWORD, | 1409 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PROXYPASSWORD, |
1427 | s->plugin->proxy_password); | 1410 | s->plugin->proxy_password); |
1428 | if (GNUNET_YES == s->plugin->proxy_use_httpproxytunnel) | 1411 | if (GNUNET_YES == s->plugin->proxy_use_httpproxytunnel) |
1429 | curl_easy_setopt (s->client_get, CURLOPT_HTTPPROXYTUNNEL, | 1412 | curl_easy_setopt (s->get.easyhandle, CURLOPT_HTTPPROXYTUNNEL, |
1430 | s->plugin->proxy_use_httpproxytunnel); | 1413 | s->plugin->proxy_use_httpproxytunnel); |
1431 | } | 1414 | } |
1432 | 1415 | ||
1433 | curl_easy_setopt (s->client_get, CURLOPT_URL, s->url); | 1416 | curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, s->url); |
1434 | //curl_easy_setopt (s->client_get, CURLOPT_HEADERFUNCTION, &curl_get_header_cb); | 1417 | //curl_easy_setopt (s->get.easyhandle, CURLOPT_HEADERFUNCTION, &curl_get_header_cb); |
1435 | //curl_easy_setopt (s->client_get, CURLOPT_WRITEHEADER, ps); | 1418 | //curl_easy_setopt (s->get.easyhandle, CURLOPT_WRITEHEADER, ps); |
1436 | curl_easy_setopt (s->client_get, CURLOPT_READFUNCTION, client_send_cb); | 1419 | curl_easy_setopt (s->get.easyhandle, CURLOPT_READFUNCTION, client_send_cb); |
1437 | curl_easy_setopt (s->client_get, CURLOPT_READDATA, s); | 1420 | curl_easy_setopt (s->get.easyhandle, CURLOPT_READDATA, s); |
1438 | curl_easy_setopt (s->client_get, CURLOPT_WRITEFUNCTION, client_receive); | 1421 | curl_easy_setopt (s->get.easyhandle, CURLOPT_WRITEFUNCTION, client_receive); |
1439 | curl_easy_setopt (s->client_get, CURLOPT_WRITEDATA, s); | 1422 | curl_easy_setopt (s->get.easyhandle, CURLOPT_WRITEDATA, s); |
1440 | /* No timeout by default, timeout done with session timeout */ | 1423 | /* No timeout by default, timeout done with session timeout */ |
1441 | curl_easy_setopt (s->client_get, CURLOPT_TIMEOUT, 0); | 1424 | curl_easy_setopt (s->get.easyhandle, CURLOPT_TIMEOUT, 0); |
1442 | curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, s); | 1425 | curl_easy_setopt (s->get.easyhandle, CURLOPT_PRIVATE, s); |
1443 | curl_easy_setopt (s->client_get, CURLOPT_CONNECTTIMEOUT_MS, | 1426 | curl_easy_setopt (s->get.easyhandle, CURLOPT_CONNECTTIMEOUT_MS, |
1444 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); | 1427 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); |
1445 | curl_easy_setopt (s->client_get, CURLOPT_BUFFERSIZE, | 1428 | curl_easy_setopt (s->get.easyhandle, CURLOPT_BUFFERSIZE, |
1446 | 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1429 | 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); |
1447 | #if CURL_TCP_NODELAY | 1430 | #if CURL_TCP_NODELAY |
1448 | curl_easy_setopt (ps->recv_endpoint, CURLOPT_TCP_NODELAY, 1); | 1431 | curl_easy_setopt (ps->recv_endpoint, CURLOPT_TCP_NODELAY, 1); |
1449 | #endif | 1432 | #endif |
1450 | curl_easy_setopt (s->client_get, CURLOPT_FOLLOWLOCATION, 0); | 1433 | curl_easy_setopt (s->get.easyhandle, CURLOPT_FOLLOWLOCATION, 0); |
1451 | 1434 | ||
1452 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, | 1435 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, |
1453 | s->client_get); | 1436 | s->get.easyhandle); |
1454 | if (CURLM_OK != mret) | 1437 | if (CURLM_OK != mret) |
1455 | { | 1438 | { |
1456 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1439 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1457 | "Session %p : Failed to add GET handle to multihandle: `%s'\n", | 1440 | "Session %p : Failed to add GET handle to multihandle: `%s'\n", |
1458 | s, | 1441 | s, |
1459 | curl_multi_strerror (mret)); | 1442 | curl_multi_strerror (mret)); |
1460 | curl_easy_cleanup (s->client_get); | 1443 | curl_easy_cleanup (s->get.easyhandle); |
1461 | s->client_get = NULL; | 1444 | s->get.easyhandle = NULL; |
1462 | s->get.s = NULL; | 1445 | s->get.s = NULL; |
1463 | s->get.easyhandle = NULL; | 1446 | s->get.easyhandle = NULL; |
1464 | GNUNET_break (0); | 1447 | GNUNET_break (0); |
@@ -1483,16 +1466,15 @@ client_connect_put (struct Session *s) | |||
1483 | /* create put connection */ | 1466 | /* create put connection */ |
1484 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1467 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1485 | "Session %p: Init PUT handle\n", s); | 1468 | "Session %p: Init PUT handle\n", s); |
1486 | s->client_put = curl_easy_init (); | 1469 | s->put.easyhandle = curl_easy_init (); |
1487 | s->put.s = s; | 1470 | s->put.s = s; |
1488 | s->put.easyhandle = s->client_put; | ||
1489 | #if VERBOSE_CURL | 1471 | #if VERBOSE_CURL |
1490 | curl_easy_setopt (s->client_put, CURLOPT_VERBOSE, 1L); | 1472 | curl_easy_setopt (s->put.easyhandle, CURLOPT_VERBOSE, 1L); |
1491 | curl_easy_setopt (s->client_put, CURLOPT_DEBUGFUNCTION, &client_log); | 1473 | curl_easy_setopt (s->put.easyhandle, CURLOPT_DEBUGFUNCTION, &client_log); |
1492 | curl_easy_setopt (s->client_put, CURLOPT_DEBUGDATA, &s->put); | 1474 | curl_easy_setopt (s->put.easyhandle, CURLOPT_DEBUGDATA, &s->put); |
1493 | #endif | 1475 | #endif |
1494 | #if BUILD_HTTPS | 1476 | #if BUILD_HTTPS |
1495 | curl_easy_setopt (s->client_put, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); | 1477 | curl_easy_setopt (s->put.easyhandle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); |
1496 | { | 1478 | { |
1497 | struct HttpAddress *ha; | 1479 | struct HttpAddress *ha; |
1498 | ha = (struct HttpAddress *) s->address->address; | 1480 | ha = (struct HttpAddress *) s->address->address; |
@@ -1500,64 +1482,64 @@ client_connect_put (struct Session *s) | |||
1500 | if (HTTP_OPTIONS_VERIFY_CERTIFICATE == | 1482 | if (HTTP_OPTIONS_VERIFY_CERTIFICATE == |
1501 | (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE)) | 1483 | (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE)) |
1502 | { | 1484 | { |
1503 | curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1L); | 1485 | curl_easy_setopt (s->put.easyhandle, CURLOPT_SSL_VERIFYPEER, 1L); |
1504 | curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 2L); | 1486 | curl_easy_setopt (s->put.easyhandle, CURLOPT_SSL_VERIFYHOST, 2L); |
1505 | } | 1487 | } |
1506 | else | 1488 | else |
1507 | { | 1489 | { |
1508 | curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 0); | 1490 | curl_easy_setopt (s->put.easyhandle, CURLOPT_SSL_VERIFYPEER, 0); |
1509 | curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 0); | 1491 | curl_easy_setopt (s->put.easyhandle, CURLOPT_SSL_VERIFYHOST, 0); |
1510 | } | 1492 | } |
1511 | } | 1493 | } |
1512 | curl_easy_setopt (s->client_put, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); | 1494 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); |
1513 | curl_easy_setopt (s->client_put, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); | 1495 | curl_easy_setopt (s->put.easyhandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS); |
1514 | #else | 1496 | #else |
1515 | curl_easy_setopt (s->client_put, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); | 1497 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP); |
1516 | curl_easy_setopt (s->client_put, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); | 1498 | curl_easy_setopt (s->put.easyhandle, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); |
1517 | #endif | 1499 | #endif |
1518 | if (s->plugin->proxy_hostname != NULL) | 1500 | if (s->plugin->proxy_hostname != NULL) |
1519 | { | 1501 | { |
1520 | curl_easy_setopt (s->client_put, CURLOPT_PROXY, s->plugin->proxy_hostname); | 1502 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PROXY, s->plugin->proxy_hostname); |
1521 | curl_easy_setopt (s->client_put, CURLOPT_PROXYTYPE, s->plugin->proxytype); | 1503 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PROXYTYPE, s->plugin->proxytype); |
1522 | if (NULL != s->plugin->proxy_username) | 1504 | if (NULL != s->plugin->proxy_username) |
1523 | curl_easy_setopt (s->client_put, CURLOPT_PROXYUSERNAME, | 1505 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PROXYUSERNAME, |
1524 | s->plugin->proxy_username); | 1506 | s->plugin->proxy_username); |
1525 | if (NULL != s->plugin->proxy_password) | 1507 | if (NULL != s->plugin->proxy_password) |
1526 | curl_easy_setopt (s->client_put, CURLOPT_PROXYPASSWORD, | 1508 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PROXYPASSWORD, |
1527 | s->plugin->proxy_password); | 1509 | s->plugin->proxy_password); |
1528 | if (GNUNET_YES == s->plugin->proxy_use_httpproxytunnel) | 1510 | if (GNUNET_YES == s->plugin->proxy_use_httpproxytunnel) |
1529 | curl_easy_setopt (s->client_put, CURLOPT_HTTPPROXYTUNNEL, | 1511 | curl_easy_setopt (s->put.easyhandle, CURLOPT_HTTPPROXYTUNNEL, |
1530 | s->plugin->proxy_use_httpproxytunnel); | 1512 | s->plugin->proxy_use_httpproxytunnel); |
1531 | } | 1513 | } |
1532 | 1514 | ||
1533 | curl_easy_setopt (s->client_put, CURLOPT_URL, s->url); | 1515 | curl_easy_setopt (s->put.easyhandle, CURLOPT_URL, s->url); |
1534 | curl_easy_setopt (s->client_put, CURLOPT_UPLOAD, 1L); | 1516 | curl_easy_setopt (s->put.easyhandle, CURLOPT_UPLOAD, 1L); |
1535 | //curl_easy_setopt (s->client_put, CURLOPT_HEADERFUNCTION, &client_curl_header); | 1517 | //curl_easy_setopt (s->put.easyhandle, CURLOPT_HEADERFUNCTION, &client_curl_header); |
1536 | //curl_easy_setopt (s->client_put, CURLOPT_WRITEHEADER, ps); | 1518 | //curl_easy_setopt (s->put.easyhandle, CURLOPT_WRITEHEADER, ps); |
1537 | curl_easy_setopt (s->client_put, CURLOPT_READFUNCTION, client_send_cb); | 1519 | curl_easy_setopt (s->put.easyhandle, CURLOPT_READFUNCTION, client_send_cb); |
1538 | curl_easy_setopt (s->client_put, CURLOPT_READDATA, s); | 1520 | curl_easy_setopt (s->put.easyhandle, CURLOPT_READDATA, s); |
1539 | curl_easy_setopt (s->client_put, CURLOPT_WRITEFUNCTION, client_receive_put); | 1521 | curl_easy_setopt (s->put.easyhandle, CURLOPT_WRITEFUNCTION, client_receive_put); |
1540 | curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, s); | 1522 | curl_easy_setopt (s->put.easyhandle, CURLOPT_WRITEDATA, s); |
1541 | /* No timeout by default, timeout done with session timeout */ | 1523 | /* No timeout by default, timeout done with session timeout */ |
1542 | curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT, 0); | 1524 | curl_easy_setopt (s->put.easyhandle, CURLOPT_TIMEOUT, 0); |
1543 | curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, s); | 1525 | curl_easy_setopt (s->put.easyhandle, CURLOPT_PRIVATE, s); |
1544 | curl_easy_setopt (s->client_put, CURLOPT_CONNECTTIMEOUT_MS, | 1526 | curl_easy_setopt (s->put.easyhandle, CURLOPT_CONNECTTIMEOUT_MS, |
1545 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); | 1527 | (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL)); |
1546 | curl_easy_setopt (s->client_put, CURLOPT_BUFFERSIZE, | 1528 | curl_easy_setopt (s->put.easyhandle, CURLOPT_BUFFERSIZE, |
1547 | 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); | 1529 | 2 * GNUNET_SERVER_MAX_MESSAGE_SIZE); |
1548 | #if CURL_TCP_NODELAY | 1530 | #if CURL_TCP_NODELAY |
1549 | curl_easy_setopt (s->client_put, CURLOPT_TCP_NODELAY, 1); | 1531 | curl_easy_setopt (s->put.easyhandle, CURLOPT_TCP_NODELAY, 1); |
1550 | #endif | 1532 | #endif |
1551 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, | 1533 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, |
1552 | s->client_put); | 1534 | s->put.easyhandle); |
1553 | if (CURLM_OK != mret) | 1535 | if (CURLM_OK != mret) |
1554 | { | 1536 | { |
1555 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1537 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1556 | "Session %p : Failed to add PUT handle to multihandle: `%s'\n", | 1538 | "Session %p : Failed to add PUT handle to multihandle: `%s'\n", |
1557 | s, | 1539 | s, |
1558 | curl_multi_strerror (mret)); | 1540 | curl_multi_strerror (mret)); |
1559 | curl_easy_cleanup (s->client_put); | 1541 | curl_easy_cleanup (s->put.easyhandle); |
1560 | s->client_put = NULL; | 1542 | s->put.easyhandle = NULL; |
1561 | s->put.easyhandle = NULL; | 1543 | s->put.easyhandle = NULL; |
1562 | s->put.s = NULL; | 1544 | s->put.s = NULL; |
1563 | s->put_tmp_disconnected = GNUNET_YES; | 1545 | s->put_tmp_disconnected = GNUNET_YES; |
@@ -1611,9 +1593,7 @@ client_connect (struct Session *s) | |||
1611 | 1593 | ||
1612 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1594 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1613 | "Session %p: connected with connections GET %p and PUT %p\n", | 1595 | "Session %p: connected with connections GET %p and PUT %p\n", |
1614 | s, | 1596 | s, s->get.easyhandle, s->put.easyhandle); |
1615 | s->client_get, | ||
1616 | s->client_put); | ||
1617 | /* Perform connect */ | 1597 | /* Perform connect */ |
1618 | GNUNET_STATISTICS_set (plugin->env->stats, | 1598 | GNUNET_STATISTICS_set (plugin->env->stats, |
1619 | HTTP_STAT_STR_CONNECTIONS, | 1599 | HTTP_STAT_STR_CONNECTIONS, |