diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-25 14:14:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-25 14:14:16 +0000 |
commit | b9b0323eefcc0a595f56635be5b66de687650ae0 (patch) | |
tree | 63017efb9b00c59d174d025242c77b425ce6f402 /src/transport/plugin_transport_http_client.c | |
parent | ca7daa5556bce347ce55933a831a8a402231ae48 (diff) | |
download | gnunet-b9b0323eefcc0a595f56635be5b66de687650ae0.tar.gz gnunet-b9b0323eefcc0a595f56635be5b66de687650ae0.zip |
-add monitor support to http server, more code clean up, add http server MHD suspend feature, support quota reset API from transport in HTTP server
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 308 |
1 files changed, 142 insertions, 166 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 68b25afe5..593b063ab 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -156,9 +156,10 @@ struct Session | |||
156 | struct HTTP_Client_Plugin *plugin; | 156 | struct HTTP_Client_Plugin *plugin; |
157 | 157 | ||
158 | /** | 158 | /** |
159 | * Client send handle | 159 | * Curl client PUT handle. |
160 | * FIXME: delta to put.easyhandle? | ||
160 | */ | 161 | */ |
161 | void *client_put; | 162 | CURL *client_put; |
162 | 163 | ||
163 | /** | 164 | /** |
164 | * Handle for the HTTP PUT request. | 165 | * Handle for the HTTP PUT request. |
@@ -166,14 +167,15 @@ struct Session | |||
166 | struct ConnectionHandle put; | 167 | struct ConnectionHandle put; |
167 | 168 | ||
168 | /** | 169 | /** |
169 | * Handle for the HTTP GET request. | 170 | * Curl client GET handle |
171 | * FIXME: delta to get.easyhandle? | ||
170 | */ | 172 | */ |
171 | struct ConnectionHandle get; | 173 | CURL *client_get; |
172 | 174 | ||
173 | /** | 175 | /** |
174 | * Client receive handle | 176 | * Handle for the HTTP GET request. |
175 | */ | 177 | */ |
176 | void *client_get; | 178 | struct ConnectionHandle get; |
177 | 179 | ||
178 | /** | 180 | /** |
179 | * next pointer for double linked list | 181 | * next pointer for double linked list |
@@ -415,6 +417,7 @@ client_delete_session (struct Session *s) | |||
415 | struct HTTP_Client_Plugin *plugin = s->plugin; | 417 | struct HTTP_Client_Plugin *plugin = s->plugin; |
416 | struct HTTP_Message *pos; | 418 | struct HTTP_Message *pos; |
417 | struct HTTP_Message *next; | 419 | struct HTTP_Message *next; |
420 | CURLMcode mret; | ||
418 | 421 | ||
419 | if (GNUNET_SCHEDULER_NO_TASK != s->timeout_task) | 422 | if (GNUNET_SCHEDULER_NO_TASK != s->timeout_task) |
420 | { | 423 | { |
@@ -427,11 +430,49 @@ client_delete_session (struct Session *s) | |||
427 | GNUNET_SCHEDULER_cancel (s->put_disconnect_task); | 430 | GNUNET_SCHEDULER_cancel (s->put_disconnect_task); |
428 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 431 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
429 | } | 432 | } |
433 | if (GNUNET_SCHEDULER_NO_TASK != s->recv_wakeup_task) | ||
434 | { | ||
435 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); | ||
436 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; | ||
437 | } | ||
430 | GNUNET_assert (GNUNET_OK == | 438 | GNUNET_assert (GNUNET_OK == |
431 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, | 439 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, |
432 | &s->target, | 440 | &s->target, |
433 | s)); | 441 | s)); |
442 | if (NULL != s->client_put) | ||
443 | { | ||
444 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
445 | "Session %p/connection %p: disconnecting PUT connection to peer `%s'\n", | ||
446 | s, | ||
447 | s->client_put, | ||
448 | GNUNET_i2s (&s->target)); | ||
434 | 449 | ||
450 | /* remove curl handle from multi handle */ | ||
451 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, | ||
452 | s->client_put); | ||
453 | GNUNET_break (CURLM_OK == mret); | ||
454 | curl_easy_cleanup (s->client_put); | ||
455 | s->client_put = NULL; | ||
456 | } | ||
457 | if (NULL != s->client_get) | ||
458 | { | ||
459 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
460 | "Session %p/connection %p: disconnecting GET connection to peer `%s'\n", | ||
461 | s, s->client_get, | ||
462 | GNUNET_i2s (&s->target)); | ||
463 | /* remove curl handle from multi handle */ | ||
464 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, | ||
465 | s->client_get); | ||
466 | GNUNET_break (CURLM_OK == mret); | ||
467 | curl_easy_cleanup (s->client_get); | ||
468 | GNUNET_assert (plugin->cur_connections > 0); | ||
469 | plugin->cur_connections--; | ||
470 | s->client_get = NULL; | ||
471 | } | ||
472 | GNUNET_STATISTICS_set (plugin->env->stats, | ||
473 | HTTP_STAT_STR_CONNECTIONS, | ||
474 | plugin->cur_connections, | ||
475 | GNUNET_NO); | ||
435 | next = s->msg_head; | 476 | next = s->msg_head; |
436 | while (NULL != (pos = next)) | 477 | while (NULL != (pos = next)) |
437 | { | 478 | { |
@@ -757,86 +798,12 @@ http_client_plugin_session_disconnect (void *cls, | |||
757 | struct Session *s) | 798 | struct Session *s) |
758 | { | 799 | { |
759 | struct HTTP_Client_Plugin *plugin = cls; | 800 | struct HTTP_Client_Plugin *plugin = cls; |
760 | struct HTTP_Message *msg; | ||
761 | struct HTTP_Message *t; | ||
762 | int res = GNUNET_OK; | ||
763 | CURLMcode mret; | ||
764 | |||
765 | if (NULL != s->client_put) | ||
766 | { | ||
767 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
768 | "Session %p/connection %p: disconnecting PUT connection to peer `%s'\n", | ||
769 | s, | ||
770 | s->client_put, | ||
771 | GNUNET_i2s (&s->target)); | ||
772 | 801 | ||
773 | /* remove curl handle from multi handle */ | ||
774 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, | ||
775 | s->client_put); | ||
776 | if (mret != CURLM_OK) | ||
777 | { | ||
778 | /* clean up easy handle, handle is now invalid and free'd */ | ||
779 | res = GNUNET_SYSERR; | ||
780 | GNUNET_break (0); | ||
781 | } | ||
782 | curl_easy_cleanup (s->client_put); | ||
783 | s->client_put = NULL; | ||
784 | } | ||
785 | |||
786 | |||
787 | if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK) | ||
788 | { | ||
789 | GNUNET_SCHEDULER_cancel (s->recv_wakeup_task); | ||
790 | s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; | ||
791 | } | ||
792 | |||
793 | if (NULL != s->client_get) | ||
794 | { | ||
795 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
796 | "Session %p/connection %p: disconnecting GET connection to peer `%s'\n", | ||
797 | s, s->client_get, | ||
798 | GNUNET_i2s (&s->target)); | ||
799 | /* remove curl handle from multi handle */ | ||
800 | mret = curl_multi_remove_handle (plugin->curl_multi_handle, s->client_get); | ||
801 | if (mret != CURLM_OK) | ||
802 | { | ||
803 | /* clean up easy handle, handle is now invalid and free'd */ | ||
804 | res = GNUNET_SYSERR; | ||
805 | GNUNET_break (0); | ||
806 | } | ||
807 | curl_easy_cleanup (s->client_get); | ||
808 | s->client_get = NULL; | ||
809 | } | ||
810 | |||
811 | msg = s->msg_head; | ||
812 | while (NULL != msg) | ||
813 | { | ||
814 | t = msg->next; | ||
815 | if (NULL != msg->transmit_cont) | ||
816 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR, | ||
817 | msg->size, msg->pos + s->overhead); | ||
818 | s->overhead = 0; | ||
819 | GNUNET_CONTAINER_DLL_remove (s->msg_head, | ||
820 | s->msg_tail, | ||
821 | msg); | ||
822 | GNUNET_assert (0 < s->msgs_in_queue); | ||
823 | s->msgs_in_queue--; | ||
824 | GNUNET_assert (msg->size <= s->bytes_in_queue); | ||
825 | s->bytes_in_queue -= msg->size; | ||
826 | GNUNET_free (msg); | ||
827 | msg = t; | ||
828 | } | ||
829 | |||
830 | GNUNET_assert (plugin->cur_connections >= 2); | ||
831 | plugin->cur_connections -= 2; | ||
832 | GNUNET_STATISTICS_set (plugin->env->stats, | ||
833 | HTTP_STAT_STR_CONNECTIONS, | ||
834 | plugin->cur_connections, | ||
835 | GNUNET_NO); | ||
836 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 802 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
837 | "Session %p: notifying transport about ending session\n",s); | 803 | "Session %p: notifying transport about ending session\n",s); |
838 | 804 | plugin->env->session_end (plugin->env->cls, | |
839 | plugin->env->session_end (plugin->env->cls, s->address, s); | 805 | s->address, |
806 | s); | ||
840 | client_delete_session (s); | 807 | client_delete_session (s); |
841 | 808 | ||
842 | /* Re-schedule since handles have changed */ | 809 | /* Re-schedule since handles have changed */ |
@@ -847,7 +814,7 @@ http_client_plugin_session_disconnect (void *cls, | |||
847 | } | 814 | } |
848 | client_schedule (plugin, GNUNET_YES); | 815 | client_schedule (plugin, GNUNET_YES); |
849 | 816 | ||
850 | return res; | 817 | return GNUNET_OK; |
851 | } | 818 | } |
852 | 819 | ||
853 | 820 | ||
@@ -993,11 +960,13 @@ client_put_disconnect (void *cls, | |||
993 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 960 | s->put_disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
994 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 961 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
995 | "Session %p/connection %p: will be disconnected due to no activity\n", | 962 | "Session %p/connection %p: will be disconnected due to no activity\n", |
996 | s, s->client_put); | 963 | s, |
964 | s->client_put); | ||
997 | s->put_paused = GNUNET_NO; | 965 | s->put_paused = GNUNET_NO; |
998 | s->put_tmp_disconnecting = GNUNET_YES; | 966 | s->put_tmp_disconnecting = GNUNET_YES; |
999 | if (NULL != s->client_put) | 967 | if (NULL != s->client_put) |
1000 | curl_easy_pause (s->client_put, CURLPAUSE_CONT); | 968 | curl_easy_pause (s->client_put, |
969 | CURLPAUSE_CONT); | ||
1001 | client_schedule (s->plugin, GNUNET_YES); | 970 | client_schedule (s->plugin, GNUNET_YES); |
1002 | } | 971 | } |
1003 | 972 | ||
@@ -1284,24 +1253,23 @@ client_run (void *cls, | |||
1284 | int running; | 1253 | int running; |
1285 | long http_statuscode; | 1254 | long http_statuscode; |
1286 | CURLMcode mret; | 1255 | CURLMcode mret; |
1256 | CURLMsg *msg; | ||
1257 | int msgs_left; | ||
1287 | 1258 | ||
1288 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; | 1259 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; |
1289 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1260 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1290 | return; | 1261 | return; |
1291 | |||
1292 | do | 1262 | do |
1293 | { | 1263 | { |
1294 | running = 0; | 1264 | running = 0; |
1295 | mret = curl_multi_perform (plugin->curl_multi_handle, &running); | 1265 | mret = curl_multi_perform (plugin->curl_multi_handle, &running); |
1296 | 1266 | ||
1297 | CURLMsg *msg; | ||
1298 | int msgs_left; | ||
1299 | 1267 | ||
1300 | while ((msg = curl_multi_info_read (plugin->curl_multi_handle, &msgs_left))) | 1268 | while ((msg = curl_multi_info_read (plugin->curl_multi_handle, &msgs_left))) |
1301 | { | 1269 | { |
1302 | CURL *easy_h = msg->easy_handle; | 1270 | CURL *easy_h = msg->easy_handle; |
1303 | struct Session *s = NULL; | 1271 | struct Session *s = NULL; |
1304 | char *d = (char *) s; | 1272 | char *d = NULL; /* curl requires 'd' to be a 'char *' */ |
1305 | 1273 | ||
1306 | if (NULL == easy_h) | 1274 | if (NULL == easy_h) |
1307 | { | 1275 | { |
@@ -1316,80 +1284,88 @@ client_run (void *cls, | |||
1316 | GNUNET_assert (CURLE_OK == | 1284 | GNUNET_assert (CURLE_OK == |
1317 | curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); | 1285 | curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); |
1318 | s = (struct Session *) d; | 1286 | s = (struct Session *) d; |
1319 | GNUNET_assert (s != NULL); | 1287 | GNUNET_assert (NULL != s); |
1320 | if (msg->msg == CURLMSG_DONE) | 1288 | if (msg->msg == CURLMSG_DONE) |
1321 | { | 1289 | { |
1322 | GNUNET_break (CURLE_OK == curl_easy_getinfo (easy_h, | 1290 | GNUNET_break (CURLE_OK == |
1323 | CURLINFO_RESPONSE_CODE, &http_statuscode)); | 1291 | curl_easy_getinfo (easy_h, |
1292 | CURLINFO_RESPONSE_CODE, | ||
1293 | &http_statuscode)); | ||
1324 | if (easy_h == s->client_put) | 1294 | if (easy_h == s->client_put) |
1325 | { | 1295 | { |
1326 | if ((0 != msg->data.result) || (http_statuscode != 200)) | 1296 | if ((0 != msg->data.result) || (http_statuscode != 200)) |
1327 | { | 1297 | { |
1328 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1298 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1329 | "Session %p/connection %p: PUT connection to `%s' ended with status %i reason %i: `%s'\n", | 1299 | "Session %p/connection %p: PUT connection to `%s' ended with status %i reason %i: `%s'\n", |
1330 | s, msg->easy_handle, | 1300 | s, msg->easy_handle, |
1331 | GNUNET_i2s (&s->target), | 1301 | GNUNET_i2s (&s->target), |
1332 | http_statuscode, | 1302 | http_statuscode, |
1333 | msg->data.result, | 1303 | msg->data.result, |
1334 | curl_easy_strerror (msg->data.result)); | 1304 | curl_easy_strerror (msg->data.result)); |
1335 | } | 1305 | } |
1336 | else | 1306 | else |
1337 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1307 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1338 | "Session %p/connection %p: PUT connection to `%s' ended normal\n", | 1308 | "Session %p/connection %p: PUT connection to `%s' ended normal\n", |
1339 | s, msg->easy_handle, | 1309 | s, msg->easy_handle, |
1340 | GNUNET_i2s (&s->target)); | 1310 | GNUNET_i2s (&s->target)); |
1341 | if (NULL == s->client_get) | 1311 | if (NULL == s->client_get) |
1342 | { | 1312 | { |
1343 | /* Disconnect other transmission direction and tell transport */ | 1313 | /* Disconnect other transmission direction and tell transport */ |
1344 | /* FIXME? */ | 1314 | /* FIXME? */ |
1345 | } | 1315 | } |
1346 | curl_multi_remove_handle (plugin->curl_multi_handle, easy_h); | 1316 | curl_multi_remove_handle (plugin->curl_multi_handle, |
1347 | curl_easy_cleanup (easy_h); | 1317 | easy_h); |
1348 | s->put_tmp_disconnecting = GNUNET_NO; | 1318 | curl_easy_cleanup (easy_h); |
1349 | s->put_tmp_disconnected = GNUNET_YES; | 1319 | GNUNET_assert (plugin->cur_connections > 0); |
1350 | s->client_put = NULL; | 1320 | plugin->cur_connections--; |
1351 | s->put.easyhandle = NULL; | 1321 | s->put_tmp_disconnecting = GNUNET_NO; |
1352 | s->put.s = NULL; | 1322 | s->put_tmp_disconnected = GNUNET_YES; |
1353 | 1323 | s->client_put = NULL; | |
1354 | /* | 1324 | s->put.easyhandle = NULL; |
1355 | * Handling a rare case: | 1325 | s->put.s = NULL; |
1356 | * plugin_send was called during temporary put disconnect, | 1326 | |
1357 | * reconnect required after connection was disconnected | 1327 | /* |
1358 | */ | 1328 | * Handling a rare case: |
1359 | if (GNUNET_YES == s->put_reconnect_required) | 1329 | * plugin_send was called during temporary put disconnect, |
1330 | * reconnect required after connection was disconnected | ||
1331 | */ | ||
1332 | if (GNUNET_YES == s->put_reconnect_required) | ||
1333 | { | ||
1334 | s->put_reconnect_required = GNUNET_NO; | ||
1335 | if (GNUNET_SYSERR == client_connect_put (s)) | ||
1360 | { | 1336 | { |
1361 | s->put_reconnect_required = GNUNET_NO; | 1337 | GNUNET_break (s->client_put == NULL); |
1362 | if (GNUNET_SYSERR == client_connect_put (s)) | 1338 | GNUNET_break (s->put_tmp_disconnected == GNUNET_NO); |
1363 | { | ||
1364 | GNUNET_break (s->client_put == NULL); | ||
1365 | GNUNET_break (s->put_tmp_disconnected == GNUNET_NO); | ||
1366 | } | ||
1367 | } | 1339 | } |
1340 | } | ||
1368 | } | 1341 | } |
1369 | if (easy_h == s->client_get) | 1342 | if (easy_h == s->client_get) |
1370 | { | 1343 | { |
1371 | if ((0 != msg->data.result) || (http_statuscode != 200)) | 1344 | if ((0 != msg->data.result) || (http_statuscode != 200)) |
1372 | { | 1345 | { |
1373 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1346 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1374 | "Session %p/connection %p: GET connection to `%s' ended with status %i reason %i: `%s'\n", | 1347 | "Session %p/connection %p: GET connection to `%s' ended with status %i reason %i: `%s'\n", |
1375 | s, | 1348 | s, |
1376 | msg->easy_handle, | 1349 | msg->easy_handle, |
1377 | GNUNET_i2s (&s->target), | 1350 | GNUNET_i2s (&s->target), |
1378 | http_statuscode, | 1351 | http_statuscode, |
1379 | msg->data.result, | 1352 | msg->data.result, |
1380 | curl_easy_strerror (msg->data.result)); | 1353 | curl_easy_strerror (msg->data.result)); |
1381 | 1354 | ||
1382 | } | 1355 | } |
1383 | else | 1356 | else |
1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1357 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1385 | "Session %p/connection %p: GET connection to `%s' ended normal\n", | 1358 | "Session %p/connection %p: GET connection to `%s' ended normal\n", |
1386 | s, | 1359 | s, |
1387 | msg->easy_handle, | 1360 | msg->easy_handle, |
1388 | GNUNET_i2s (&s->target)); | 1361 | GNUNET_i2s (&s->target)); |
1389 | /* Disconnect other transmission direction and tell transport */ | 1362 | /* Disconnect other transmission direction and tell transport */ |
1390 | s->get.easyhandle = NULL; | 1363 | s->get.easyhandle = NULL; |
1391 | s->get.s = NULL; | 1364 | s->get.s = NULL; |
1392 | http_client_plugin_session_disconnect (plugin, s); | 1365 | /* FIXME: who calls curl_multi_remove on 'easy_h' now!? */ |
1366 | GNUNET_assert (plugin->cur_connections > 0); | ||
1367 | plugin->cur_connections--; | ||
1368 | http_client_plugin_session_disconnect (plugin, s); | ||
1393 | } | 1369 | } |
1394 | } | 1370 | } |
1395 | } | 1371 | } |
@@ -1423,6 +1399,7 @@ client_connect_get (struct Session *s) | |||
1423 | curl_easy_setopt (s->client_get, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); | 1399 | curl_easy_setopt (s->client_get, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); |
1424 | { | 1400 | { |
1425 | struct HttpAddress *ha; | 1401 | struct HttpAddress *ha; |
1402 | |||
1426 | ha = (struct HttpAddress *) s->address->address; | 1403 | ha = (struct HttpAddress *) s->address->address; |
1427 | 1404 | ||
1428 | if (HTTP_OPTIONS_VERIFY_CERTIFICATE == | 1405 | if (HTTP_OPTIONS_VERIFY_CERTIFICATE == |
@@ -1444,7 +1421,7 @@ client_connect_get (struct Session *s) | |||
1444 | curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); | 1421 | curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP); |
1445 | #endif | 1422 | #endif |
1446 | 1423 | ||
1447 | if (s->plugin->proxy_hostname != NULL) | 1424 | if (NULL != s->plugin->proxy_hostname) |
1448 | { | 1425 | { |
1449 | curl_easy_setopt (s->client_get, CURLOPT_PROXY, s->plugin->proxy_hostname); | 1426 | curl_easy_setopt (s->client_get, CURLOPT_PROXY, s->plugin->proxy_hostname); |
1450 | curl_easy_setopt (s->client_get, CURLOPT_PROXYTYPE, s->plugin->proxytype); | 1427 | curl_easy_setopt (s->client_get, CURLOPT_PROXYTYPE, s->plugin->proxytype); |
@@ -1478,8 +1455,9 @@ client_connect_get (struct Session *s) | |||
1478 | #endif | 1455 | #endif |
1479 | curl_easy_setopt (s->client_get, CURLOPT_FOLLOWLOCATION, 0); | 1456 | curl_easy_setopt (s->client_get, CURLOPT_FOLLOWLOCATION, 0); |
1480 | 1457 | ||
1481 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, s->client_get); | 1458 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, |
1482 | if (mret != CURLM_OK) | 1459 | s->client_get); |
1460 | if (CURLM_OK != mret) | ||
1483 | { | 1461 | { |
1484 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1462 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1485 | "Session %p : Failed to add GET handle to multihandle: `%s'\n", | 1463 | "Session %p : Failed to add GET handle to multihandle: `%s'\n", |
@@ -1492,7 +1470,7 @@ client_connect_get (struct Session *s) | |||
1492 | GNUNET_break (0); | 1470 | GNUNET_break (0); |
1493 | return GNUNET_SYSERR; | 1471 | return GNUNET_SYSERR; |
1494 | } | 1472 | } |
1495 | 1473 | s->plugin->cur_connections++; | |
1496 | return GNUNET_OK; | 1474 | return GNUNET_OK; |
1497 | } | 1475 | } |
1498 | 1476 | ||
@@ -1576,8 +1554,9 @@ client_connect_put (struct Session *s) | |||
1576 | #if CURL_TCP_NODELAY | 1554 | #if CURL_TCP_NODELAY |
1577 | curl_easy_setopt (s->client_put, CURLOPT_TCP_NODELAY, 1); | 1555 | curl_easy_setopt (s->client_put, CURLOPT_TCP_NODELAY, 1); |
1578 | #endif | 1556 | #endif |
1579 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, s->client_put); | 1557 | mret = curl_multi_add_handle (s->plugin->curl_multi_handle, |
1580 | if (mret != CURLM_OK) | 1558 | s->client_put); |
1559 | if (CURLM_OK != mret) | ||
1581 | { | 1560 | { |
1582 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1561 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1583 | "Session %p : Failed to add PUT handle to multihandle: `%s'\n", | 1562 | "Session %p : Failed to add PUT handle to multihandle: `%s'\n", |
@@ -1591,6 +1570,8 @@ client_connect_put (struct Session *s) | |||
1591 | return GNUNET_SYSERR; | 1570 | return GNUNET_SYSERR; |
1592 | } | 1571 | } |
1593 | s->put_tmp_disconnected = GNUNET_NO; | 1572 | s->put_tmp_disconnected = GNUNET_NO; |
1573 | s->plugin->cur_connections++; | ||
1574 | |||
1594 | return GNUNET_OK; | 1575 | return GNUNET_OK; |
1595 | } | 1576 | } |
1596 | 1577 | ||
@@ -1632,11 +1613,7 @@ client_connect (struct Session *s) | |||
1632 | 1613 | ||
1633 | if ((GNUNET_SYSERR == client_connect_get (s)) || | 1614 | if ((GNUNET_SYSERR == client_connect_get (s)) || |
1634 | (GNUNET_SYSERR == client_connect_put (s))) | 1615 | (GNUNET_SYSERR == client_connect_put (s))) |
1635 | { | ||
1636 | plugin->env->session_end (plugin->env->cls, s->address, s); | ||
1637 | client_delete_session (s); | ||
1638 | return GNUNET_SYSERR; | 1616 | return GNUNET_SYSERR; |
1639 | } | ||
1640 | 1617 | ||
1641 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1618 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1642 | "Session %p: connected with connections GET %p and PUT %p\n", | 1619 | "Session %p: connected with connections GET %p and PUT %p\n", |
@@ -1644,7 +1621,6 @@ client_connect (struct Session *s) | |||
1644 | s->client_get, | 1621 | s->client_get, |
1645 | s->client_put); | 1622 | s->client_put); |
1646 | /* Perform connect */ | 1623 | /* Perform connect */ |
1647 | plugin->cur_connections += 2; | ||
1648 | GNUNET_STATISTICS_set (plugin->env->stats, | 1624 | GNUNET_STATISTICS_set (plugin->env->stats, |
1649 | HTTP_STAT_STR_CONNECTIONS, | 1625 | HTTP_STAT_STR_CONNECTIONS, |
1650 | plugin->cur_connections, | 1626 | plugin->cur_connections, |