aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-06-28 15:24:41 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-06-28 15:24:41 +0000
commitceae03698d503c88e96d18984e11079cb95a2184 (patch)
tree321787a5803b5f475b16c1a1f8d756060b894c3a
parentabe735c1cb91b2f1e4fe32a2444d7951b05a9e83 (diff)
downloadgnunet-ceae03698d503c88e96d18984e11079cb95a2184.tar.gz
gnunet-ceae03698d503c88e96d18984e11079cb95a2184.zip
-rw-r--r--src/transport/plugin_transport_http.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index c809b2c3e..905105ce3 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -41,7 +41,7 @@
41#include <curl/curl.h> 41#include <curl/curl.h>
42 42
43 43
44#define DEBUG_CURL GNUNET_YES 44#define DEBUG_CURL GNUNET_NO
45#define DEBUG_HTTP GNUNET_NO 45#define DEBUG_HTTP GNUNET_NO
46#define HTTP_CONNECT_TIMEOUT_DBG 10 46#define HTTP_CONNECT_TIMEOUT_DBG 10
47 47
@@ -897,6 +897,7 @@ static size_t send_read_callback(void *stream, size_t size, size_t nmemb, void *
897 897
898 if (con->pending_msgs_tail == NULL) 898 if (con->pending_msgs_tail == NULL)
899 { 899 {
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection: %X: No Message to send, pausing connection\n",con);
900 con->send_paused = GNUNET_YES; 901 con->send_paused = GNUNET_YES;
901 return CURL_READFUNC_PAUSE; 902 return CURL_READFUNC_PAUSE;
902 } 903 }
@@ -929,7 +930,7 @@ static size_t send_read_callback(void *stream, size_t size, size_t nmemb, void *
929 930
930 if ( msg->pos == msg->size) 931 if ( msg->pos == msg->size)
931 { 932 {
932 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Messge %u bytes sent, removing message from queue \n", msg->pos); 933 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection: %X: Message with %u bytes sent, removing message from queue \n",con, msg->pos);
933 /* Calling transmit continuation */ 934 /* Calling transmit continuation */
934 if (( NULL != con->pending_msgs_tail) && (NULL != con->pending_msgs_tail->transmit_cont)) 935 if (( NULL != con->pending_msgs_tail) && (NULL != con->pending_msgs_tail->transmit_cont))
935 msg->transmit_cont (con->pending_msgs_tail->transmit_cont_cls,&(con->session)->identity,GNUNET_OK); 936 msg->transmit_cont (con->pending_msgs_tail->transmit_cont_cls,&(con->session)->identity,GNUNET_OK);
@@ -985,12 +986,16 @@ static ssize_t send_initiate (void *cls, struct Session* ses , struct HTTP_Conne
985 986
986 /* already connected, no need to initiate connection */ 987 /* already connected, no need to initiate connection */
987 if ((con->connected == GNUNET_YES) && (con->curl_handle != NULL) && (con->send_paused == GNUNET_NO)) 988 if ((con->connected == GNUNET_YES) && (con->curl_handle != NULL) && (con->send_paused == GNUNET_NO))
989 {
990 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection: %X: active, enqueueing message\n",con);
988 return bytes_sent; 991 return bytes_sent;
992 }
989 993
990 if ((con->connected == GNUNET_YES) && (con->curl_handle != NULL) && (con->send_paused == GNUNET_YES)) 994 if ((con->connected == GNUNET_YES) && (con->curl_handle != NULL) && (con->send_paused == GNUNET_YES))
991 { 995 {
992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"UNPAUSING\n"); 996 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection: %X: paused, unpausing existing connection and enqueueing message\n",con);
993 curl_easy_pause(con->curl_handle,CURLPAUSE_CONT); 997 curl_easy_pause(con->curl_handle,CURLPAUSE_CONT);
998 con->send_paused=GNUNET_NO;
994 return bytes_sent; 999 return bytes_sent;
995 } 1000 }
996 1001
@@ -1000,8 +1005,7 @@ static ssize_t send_initiate (void *cls, struct Session* ses , struct HTTP_Conne
1000 if ( NULL == con->curl_handle) 1005 if ( NULL == con->curl_handle)
1001 con->curl_handle = curl_easy_init(); 1006 con->curl_handle = curl_easy_init();
1002 GNUNET_assert (con->curl_handle != NULL); 1007 GNUNET_assert (con->curl_handle != NULL);
1003 1008 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection: %X: not existing, creating new connection\n",con);
1004
1005 1009
1006 GNUNET_assert (NULL != con->pending_msgs_tail); 1010 GNUNET_assert (NULL != con->pending_msgs_tail);
1007 msg = con->pending_msgs_tail; 1011 msg = con->pending_msgs_tail;
@@ -1295,9 +1299,26 @@ static void
1295http_plugin_disconnect (void *cls, 1299http_plugin_disconnect (void *cls,
1296 const struct GNUNET_PeerIdentity *target) 1300 const struct GNUNET_PeerIdentity *target)
1297{ 1301{
1298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Plugin: http_plugin_disconnect\n"); 1302 struct Plugin *plugin = cls;
1299 // struct Plugin *plugin = cls; 1303 struct HTTP_Connection_out *con;
1300 // FIXME 1304 struct Session *cs;
1305
1306 /* get session from hashmap */
1307 cs = session_get(plugin, target);
1308 con = cs->outbound_connections_head;
1309
1310 while (con!=NULL)
1311 {
1312 if (con->curl_handle!=NULL)
1313 curl_easy_cleanup(con->curl_handle);
1314 con->curl_handle=NULL;
1315 con->connected = GNUNET_NO;
1316 while (con->pending_msgs_head!=NULL)
1317 {
1318 remove_http_message(con, con->pending_msgs_head);
1319 }
1320 con=con->next;
1321 }
1301} 1322}
1302 1323
1303 1324