aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-07-05 12:42:15 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-07-05 12:42:15 +0000
commit5f1e438c5995d178d25f21f199a0026eaf631dd8 (patch)
treed4c02f545b48328783cec79a9d3c7a88288b7ea6 /src/transport
parent53f7395bed9850cab4c1ec98a565f190e138dbb2 (diff)
downloadgnunet-5f1e438c5995d178d25f21f199a0026eaf631dd8.tar.gz
gnunet-5f1e438c5995d178d25f21f199a0026eaf631dd8.zip
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_http.c105
1 files changed, 52 insertions, 53 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index db846094c..78e513857 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -1061,7 +1061,7 @@ static void http_server_daemon_v6_run (void *cls,
1061 1061
1062static size_t curl_header_function( void *ptr, size_t size, size_t nmemb, void *stream) 1062static size_t curl_header_function( void *ptr, size_t size, size_t nmemb, void *stream)
1063{ 1063{
1064 struct HTTP_Connection * con = stream; 1064 struct HTTP_Session * ps = stream;
1065 1065
1066 char * tmp; 1066 char * tmp;
1067 size_t len = size * nmemb; 1067 size_t len = size * nmemb;
@@ -1069,16 +1069,16 @@ static size_t curl_header_function( void *ptr, size_t size, size_t nmemb, void *
1069 int res; 1069 int res;
1070 1070
1071 /* Getting last http result code */ 1071 /* Getting last http result code */
1072 if (con->get_connected==GNUNET_NO) 1072 if (ps->recv_connected==GNUNET_NO)
1073 { 1073 {
1074 GNUNET_assert(NULL!=con); 1074 GNUNET_assert(NULL!=ps);
1075 res = curl_easy_getinfo(con->get_curl_handle, CURLINFO_RESPONSE_CODE, &http_result); 1075 res = curl_easy_getinfo(ps->recv_endpoint, CURLINFO_RESPONSE_CODE, &http_result);
1076 if (CURLE_OK == res) 1076 if (CURLE_OK == res)
1077 { 1077 {
1078 if (http_result == 200) 1078 if (http_result == 200)
1079 { 1079 {
1080 con->get_connected = GNUNET_YES; 1080 ps->recv_connected = GNUNET_YES;
1081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound connected\n",con); 1081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound connected\n",ps);
1082 } 1082 }
1083 } 1083 }
1084 } 1084 }
@@ -1176,10 +1176,10 @@ static size_t send_curl_read_callback(void *stream, size_t size, size_t nmemb, v
1176*/ 1176*/
1177static size_t send_curl_write_callback( void *stream, size_t size, size_t nmemb, void *ptr) 1177static size_t send_curl_write_callback( void *stream, size_t size, size_t nmemb, void *ptr)
1178{ 1178{
1179 struct HTTP_Connection * con = ptr; 1179 struct HTTP_Session * ps = ptr;
1180 1180
1181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes recieved\n",con, size*nmemb); 1181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes recieved\n",ps, size*nmemb);
1182 GNUNET_SERVER_mst_receive(con->get_msgtok, con, stream,size*nmemb, GNUNET_NO, GNUNET_NO); 1182 GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, GNUNET_NO);
1183 1183
1184 return (size * nmemb); 1184 return (size * nmemb);
1185 1185
@@ -1322,8 +1322,8 @@ static void send_execute (void *cls,
1322 int running; 1322 int running;
1323 struct CURLMsg *msg; 1323 struct CURLMsg *msg;
1324 CURLMcode mret; 1324 CURLMcode mret;
1325 struct HTTP_Connection * con = NULL; 1325 struct HTTP_Session *ps = NULL;
1326 struct Session * cs = NULL; 1326 struct HTTP_PeerContext *pc = NULL;
1327 long http_result; 1327 long http_result;
1328 1328
1329 GNUNET_assert(cls !=NULL); 1329 GNUNET_assert(cls !=NULL);
@@ -1345,10 +1345,10 @@ static void send_execute (void *cls,
1345 break; 1345 break;
1346 /* get session for affected curl handle */ 1346 /* get session for affected curl handle */
1347 GNUNET_assert ( msg->easy_handle != NULL ); 1347 GNUNET_assert ( msg->easy_handle != NULL );
1348 curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, (char *) &con); 1348 curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, (char *) &ps);
1349 GNUNET_assert ( con != NULL ); 1349 GNUNET_assert ( ps != NULL );
1350 cs = con->session; 1350 pc = ps->peercontext;
1351 GNUNET_assert ( cs != NULL ); 1351 GNUNET_assert ( pc != NULL );
1352 switch (msg->msg) 1352 switch (msg->msg)
1353 { 1353 {
1354 1354
@@ -1357,85 +1357,84 @@ static void send_execute (void *cls,
1357 (msg->data.result != CURLE_GOT_NOTHING) ) 1357 (msg->data.result != CURLE_GOT_NOTHING) )
1358 { 1358 {
1359 /* sending msg failed*/ 1359 /* sending msg failed*/
1360 if (msg->easy_handle == con->put_curl_handle) 1360 if (msg->easy_handle == ps->send_endpoint)
1361 { 1361 {
1362 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1362 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1363 _("Connection %X: HTTP PUT to peer `%s' (`%s') failed: `%s' `%s'\n"), 1363 _("Connection %X: HTTP PUT to peer `%s' (`%s') failed: `%s' `%s'\n"),
1364 con, 1364 ps,
1365 GNUNET_i2s(&cs->identity), 1365 GNUNET_i2s(&pc->identity),
1366 http_plugin_address_to_string(NULL, con->addr, con->addrlen), 1366 http_plugin_address_to_string(NULL, ps->addr, ps->addrlen),
1367 "curl_multi_perform", 1367 "curl_multi_perform",
1368 curl_easy_strerror (msg->data.result)); 1368 curl_easy_strerror (msg->data.result));
1369 1369
1370 con->put_connected = GNUNET_NO; 1370 ps->send_connected = GNUNET_NO;
1371 curl_easy_cleanup(con->put_curl_handle); 1371 curl_easy_cleanup(ps->send_endpoint);
1372 con->put_curl_handle=NULL; 1372 ps->send_endpoint=NULL;
1373 if (( NULL != con->pending_msgs_tail) && ( NULL != con->pending_msgs_tail->transmit_cont)) 1373 if (( NULL != ps->pending_msgs_tail) && ( NULL != ps->pending_msgs_tail->transmit_cont))
1374 con->pending_msgs_tail->transmit_cont (con->pending_msgs_tail->transmit_cont_cls,&con->session->identity,GNUNET_SYSERR); 1374 ps->pending_msgs_tail->transmit_cont (ps->pending_msgs_tail->transmit_cont_cls,&pc->identity,GNUNET_SYSERR);
1375 } 1375 }
1376 /* GET connection failed */ 1376 /* GET connection failed */
1377 if (msg->easy_handle == con->get_curl_handle) 1377 if (msg->easy_handle == ps->recv_endpoint)
1378 { 1378 {
1379 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 1379 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
1380 _("Connection %X: HTTP GET to peer `%s' (`%s') failed: `%s' `%s'\n"), 1380 _("Connection %X: HTTP GET to peer `%s' (`%s') failed: `%s' `%s'\n"),
1381 con, 1381 ps,
1382 GNUNET_i2s(&cs->identity), 1382 GNUNET_i2s(&pc->identity),
1383 http_plugin_address_to_string(NULL, con->addr, con->addrlen), 1383 http_plugin_address_to_string(NULL, ps->addr, ps->addrlen),
1384 "curl_multi_perform", 1384 "curl_multi_perform",
1385 curl_easy_strerror (msg->data.result)); 1385 curl_easy_strerror (msg->data.result));
1386 con->get_connected = GNUNET_NO; 1386 ps->recv_connected = GNUNET_NO;
1387 curl_easy_cleanup(con->get_curl_handle); 1387 curl_easy_cleanup(ps->recv_endpoint);
1388 con->get_curl_handle=NULL; 1388 ps->recv_endpoint=NULL;
1389 } 1389 }
1390 } 1390 }
1391 else 1391 else
1392 { 1392 {
1393 if (msg->easy_handle == con->put_curl_handle) 1393 if (msg->easy_handle == ps->send_endpoint)
1394 { 1394 {
1395 GNUNET_assert (CURLE_OK == curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &http_result)); 1395 GNUNET_assert (CURLE_OK == curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &http_result));
1396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1397 "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", 1397 "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n",
1398 con, 1398 ps,
1399 GNUNET_i2s(&cs->identity), 1399 GNUNET_i2s(&pc->identity),
1400 http_plugin_address_to_string(NULL, con->addr, con->addrlen), 1400 http_plugin_address_to_string(NULL, ps->addr, ps->addrlen),
1401 http_result); 1401 http_result);
1402 1402
1403 /* Calling transmit continuation */ 1403 /* Calling transmit continuation */
1404 if (( NULL != con->pending_msgs_tail) && (NULL != con->pending_msgs_tail->transmit_cont)) 1404 if (( NULL != ps->pending_msgs_tail) && (NULL != ps->pending_msgs_tail->transmit_cont))
1405 { 1405 {
1406 /* HTTP 1xx : Last message before here was informational */ 1406 /* HTTP 1xx : Last message before here was informational */
1407 if ((http_result >=100) && (http_result < 200)) 1407 if ((http_result >=100) && (http_result < 200))
1408 con->pending_msgs_tail->transmit_cont (con->pending_msgs_tail->transmit_cont_cls,&cs->identity,GNUNET_OK); 1408 ps->pending_msgs_tail->transmit_cont (ps->pending_msgs_tail->transmit_cont_cls,&pc->identity,GNUNET_OK);
1409 /* HTTP 2xx: successful operations */ 1409 /* HTTP 2xx: successful operations */
1410 if ((http_result >=200) && (http_result < 300)) 1410 if ((http_result >=200) && (http_result < 300))
1411 con->pending_msgs_tail->transmit_cont (con->pending_msgs_tail->transmit_cont_cls,&cs->identity,GNUNET_OK); 1411 ps->pending_msgs_tail->transmit_cont (ps->pending_msgs_tail->transmit_cont_cls,&pc->identity,GNUNET_OK);
1412 /* HTTP 3xx..5xx: error */ 1412 /* HTTP 3xx..5xx: error */
1413 if ((http_result >=300) && (http_result < 600)) 1413 if ((http_result >=300) && (http_result < 600))
1414 con->pending_msgs_tail->transmit_cont (con->pending_msgs_tail->transmit_cont_cls,&cs->identity,GNUNET_SYSERR); 1414 ps->pending_msgs_tail->transmit_cont (ps->pending_msgs_tail->transmit_cont_cls,&pc->identity,GNUNET_SYSERR);
1415 } 1415 }
1416 curl_easy_cleanup(con->put_curl_handle); 1416 ps->send_connected = GNUNET_NO;
1417 con->put_connected = GNUNET_NO; 1417 curl_easy_cleanup(ps->send_endpoint);
1418 con->put_curl_handle=NULL; 1418 ps->send_endpoint =NULL;
1419 } 1419 }
1420 if (msg->easy_handle == con->get_curl_handle) 1420 if (msg->easy_handle == ps->recv_endpoint)
1421 { 1421 {
1422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1423 "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", 1423 "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n",
1424 con, 1424 ps,
1425 GNUNET_i2s(&cs->identity), 1425 GNUNET_i2s(&pc->identity),
1426 http_plugin_address_to_string(NULL, con->addr, con->addrlen), 1426 http_plugin_address_to_string(NULL, ps->addr, ps->addrlen),
1427 http_result); 1427 http_result);
1428 1428
1429 con->get_connected = GNUNET_NO; 1429 ps->recv_connected = GNUNET_NO;
1430 curl_easy_cleanup(con->get_curl_handle); 1430 curl_easy_cleanup(ps->recv_endpoint);
1431 con->get_curl_handle=NULL; 1431 ps->recv_endpoint=NULL;
1432 } 1432 }
1433 } 1433 }
1434 if (con->pending_msgs_tail != NULL) 1434 if (ps->pending_msgs_tail != NULL)
1435 { 1435 {
1436 if (con->pending_msgs_tail->pos>0) 1436 if (ps->pending_msgs_tail->pos>0)
1437 remove_http_message(con, con->pending_msgs_tail); 1437 remove_http_message(ps, ps->pending_msgs_tail);
1438 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message could not be removed from session `%s'\n", GNUNET_i2s(&cs->identity));
1439 } 1438 }
1440 return; 1439 return;
1441 default: 1440 default: