aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-07-06 13:15:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-07-06 13:15:20 +0000
commita119335e8c9169b06a712ab50be2b2c64a7a9ee0 (patch)
tree299cbbdb501edd1d2b4e2024bc0f18f440163cbb
parent911c190c1f1ab50c31a697dc23231ae8a46955fe (diff)
downloadgnunet-a119335e8c9169b06a712ab50be2b2c64a7a9ee0.tar.gz
gnunet-a119335e8c9169b06a712ab50be2b2c64a7a9ee0.zip
-rw-r--r--src/transport/plugin_transport_http.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 4e172e55f..3421169ee 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -237,6 +237,11 @@ struct Session
237 unsigned int send_active; 237 unsigned int send_active;
238 238
239 /** 239 /**
240 * connection disconnect forced (e.g. from transport)
241 */
242 unsigned int send_force_disconnect;
243
244 /**
240 * is session connected to receive data? 245 * is session connected to receive data?
241 */ 246 */
242 unsigned int recv_connected; 247 unsigned int recv_connected;
@@ -247,6 +252,11 @@ struct Session
247 unsigned int recv_active; 252 unsigned int recv_active;
248 253
249 /** 254 /**
255 * connection disconnect forced (e.g. from transport)
256 */
257 unsigned int recv_force_disconnect;
258
259 /**
250 * entity managing sending data 260 * entity managing sending data
251 * outbound session: pointer to curl easy handle 261 * outbound session: pointer to curl easy handle
252 */ 262 */
@@ -387,12 +397,12 @@ static void requestCompletedCallback (void *cls, struct MHD_Connection * connect
387 struct Session * ps = *httpSessionCache; 397 struct Session * ps = *httpSessionCache;
388 if (ps == NULL) 398 if (ps == NULL)
389 return; 399 return;
400
390#if DEBUG_CONNECTIONS 401#if DEBUG_CONNECTIONS
391 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was terminated\n",GNUNET_i2s(&ps->peercontext->identity)); 402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: connection from peer `%s' was terminated\n", ps, GNUNET_i2s(&ps->peercontext->identity));
392#endif 403#endif
393 /* session set to inactive */ 404 /* session set to inactive */
394 //ps-> = GNUNET_NO; 405 //ps-> = GNUNET_NO;
395 //con->is_bad_request = GNUNET_NO;
396} 406}
397 407
398static void mhd_write_mst_cb (void *cls, 408static void mhd_write_mst_cb (void *cls,
@@ -468,6 +478,14 @@ int server_read_callback (void *cls, uint64_t pos, char *buf, int max)
468 pc = ps->peercontext; 478 pc = ps->peercontext;
469 msg = ps->pending_msgs_tail; 479 msg = ps->pending_msgs_tail;
470 480
481 if (ps->send_force_disconnect)
482 {
483#if DEBUG_CONNECTIONS
484 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound forced to disconnect\n",ps);
485#endif
486 return -1;
487 }
488
471 if (msg!=NULL) 489 if (msg!=NULL)
472 { 490 {
473 if ((msg->size-msg->pos) <= max) 491 if ((msg->size-msg->pos) <= max)
@@ -621,6 +639,15 @@ accessHandlerCallback (void *cls,
621 /* Is it a PUT or a GET request */ 639 /* Is it a PUT or a GET request */
622 if (0 == strcmp (MHD_HTTP_METHOD_PUT, method)) 640 if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
623 { 641 {
642 if (ps->recv_force_disconnect)
643 {
644#if DEBUG_CONNECTIONS
645 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound forced to disconnect\n",ps);
646#endif
647 ps->recv_connected = GNUNET_NO;
648 ps->recv_active = GNUNET_NO;
649 return MHD_NO;
650 }
624 if ((*upload_data_size == 0) && (ps->recv_active==GNUNET_NO)) 651 if ((*upload_data_size == 0) && (ps->recv_active==GNUNET_NO))
625 { 652 {
626 ps->recv_active = GNUNET_YES; 653 ps->recv_active = GNUNET_YES;
@@ -652,6 +679,15 @@ accessHandlerCallback (void *cls,
652 } 679 }
653 if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) ) 680 if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
654 { 681 {
682 if (ps->send_force_disconnect)
683 {
684#if DEBUG_CONNECTIONS
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound forced to disconnect\n",ps);
686#endif
687 ps->send_connected = GNUNET_NO;
688 ps->send_active = GNUNET_NO;
689 return MHD_NO;
690 }
655 response = MHD_create_response_from_callback(-1,32 * 1024, &server_read_callback, ps, NULL); 691 response = MHD_create_response_from_callback(-1,32 * 1024, &server_read_callback, ps, NULL);
656 res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); 692 res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
657 MHD_destroy_response (response); 693 MHD_destroy_response (response);
@@ -1539,7 +1575,8 @@ http_plugin_disconnect (void *cls,
1539 } 1575 }
1540 if (ps->direction==INBOUND) 1576 if (ps->direction==INBOUND)
1541 { 1577 {
1542 1578 ps->recv_force_disconnect = GNUNET_YES;
1579 ps->send_force_disconnect = GNUNET_YES;
1543 } 1580 }
1544 while (ps->pending_msgs_head!=NULL) 1581 while (ps->pending_msgs_head!=NULL)
1545 { 1582 {