gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r12173 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r12173 - gnunet/src/transport
Date: Tue, 6 Jul 2010 14:45:34 +0200

Author: wachs
Date: 2010-07-06 14:45:34 +0200 (Tue, 06 Jul 2010)
New Revision: 12173

Modified:
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/test_plugin_transport_http.c
Log:


Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-07-06 12:25:33 UTC 
(rev 12172)
+++ gnunet/src/transport/plugin_transport_http.c        2010-07-06 12:45:34 UTC 
(rev 12173)
@@ -42,6 +42,7 @@
 
 #define DEBUG_CURL GNUNET_NO
 #define DEBUG_HTTP GNUNET_NO
+#define DEBUG_CONNECTIONS GNUNET_NO
 
 #define INBOUND GNUNET_NO
 #define OUTBOUND GNUNET_YES
@@ -386,7 +387,9 @@
   struct Session * ps = *httpSessionCache;
   if (ps == NULL)
     return;
+#if DEBUG_CONNECTIONS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was 
terminated\n",GNUNET_i2s(&ps->peercontext->identity));
+#endif
   /* session set to inactive */
   //ps-> = GNUNET_NO;
   //con->is_bad_request = GNUNET_NO;
@@ -629,7 +632,9 @@
     {
       response = MHD_create_response_from_data (strlen 
(HTTP_PUT_RESPONSE),HTTP_PUT_RESPONSE, MHD_NO, MHD_NO);
       res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sent HTTP/1.1: 200 OK as PUT 
Response\n",HTTP_PUT_RESPONSE, strlen (HTTP_PUT_RESPONSE), res );
+#if DEBUG_CONNECTIONS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Sent HTTP/1.1: 200 
OK as PUT Response\n",ps);
+#endif
       MHD_destroy_response (response);
       ps->recv_active=GNUNET_NO;
       return MHD_YES;
@@ -810,7 +815,9 @@
       {
         ps->recv_connected = GNUNET_YES;
         ps->recv_active = GNUNET_YES;
+#if DEBUG_CONNECTIONS
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: connected to 
recieve data\n",ps);
+#endif
         // Calling send_check_connections again since receive is established
         send_check_connections (ps->peercontext->plugin, NULL, ps);
       }
@@ -857,13 +864,17 @@
     {
       ps->send_connected = GNUNET_YES;
       ps->send_active = GNUNET_YES;
+#if DEBUG_CONNECTIONS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: connected to send 
data\n",ps);
+#endif
     }
     if ((http_result == 200) && (ps->send_connected==GNUNET_YES))
     {
       ps->send_connected = GNUNET_NO;
       ps->send_active = GNUNET_NO;
+#if DEBUG_CONNECTIONS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: sending 
disconnected\n",ps);
+#endif
     }
   }
 
@@ -907,7 +918,9 @@
 
   if (ps->pending_msgs_tail == NULL)
   {
+#if DEBUG_CONNECTIONS
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: No Message to send, 
pausing connection\n",ps);
+#endif
     ps->send_active = GNUNET_NO;
     return CURL_READFUNC_PAUSE;
   }
@@ -940,7 +953,9 @@
 
   if ( msg->pos == msg->size)
   {
+#if DEBUG_CONNECTIONS
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Message with %u bytes 
sent, removing message from queue \n",ps, msg->pos);
+#endif
     /* Calling transmit continuation  */
     if (( NULL != ps->pending_msgs_tail) && (NULL != 
ps->pending_msgs_tail->transmit_cont))
       msg->transmit_cont 
(ps->pending_msgs_tail->transmit_cont_cls,&(ps->peercontext)->identity,GNUNET_OK);
@@ -961,8 +976,9 @@
 static size_t send_curl_receive_callback( void *stream, size_t size, size_t 
nmemb, void *ptr)
 {
   struct Session * ps = ptr;
-
+#if DEBUG_CONNECTIONS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: %u bytes recieved\n",ps, 
size*nmemb);
+#endif
   GNUNET_SERVER_mst_receive(ps->msgtok, ps, stream, size*nmemb, GNUNET_NO, 
GNUNET_NO);
 
   return (size * nmemb);
@@ -1032,7 +1048,9 @@
         bytes_sent = send_schedule (plugin, NULL);
         if (ps->msgtok != NULL)
           ps->msgtok = GNUNET_SERVER_mst_create (&curl_write_mst_cb, ps);
+#if DEBUG_CONNECTIONS
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound not 
connected, initiating connection\n",ps);
+#endif
       }
     }
 
@@ -1046,12 +1064,16 @@
     {
       if (ps->send_active == GNUNET_YES)
       {
+#if DEBUG_CONNECTIONS
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound active, 
enqueueing message\n",ps);
+#endif
         return bytes_sent;
       }
       if (ps->send_active == GNUNET_NO)
       {
+#if DEBUG_CONNECTIONS
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound paused, 
unpausing existing connection and enqueueing message\n",ps);
+#endif
         curl_easy_pause(ps->send_endpoint,CURLPAUSE_CONT);
         ps->send_active=GNUNET_YES;
         return bytes_sent;
@@ -1062,7 +1084,9 @@
       ps->send_endpoint = curl_easy_init();
     GNUNET_assert (ps->send_endpoint != NULL);
     GNUNET_assert (NULL != ps->pending_msgs_tail);
+#if DEBUG_CONNECTIONS
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound not 
connected, initiating connection\n",ps);
+#endif
     ps->send_active = GNUNET_NO;
     msg = ps->pending_msgs_tail;
 
@@ -1097,8 +1121,9 @@
   if (ps->direction == INBOUND)
   {
     GNUNET_assert (NULL != ps->pending_msgs_tail);
+    bytes_sent = 0;
     msg = ps->pending_msgs_tail;
-    if ((ps->recv_connected==GNUNET_YES) && (ps->recv_connected==GNUNET_YES))
+    if ((ps->recv_connected==GNUNET_YES) && (ps->send_connected==GNUNET_YES))
         bytes_sent = msg->size;
     return bytes_sent;
   }
@@ -1151,6 +1176,7 @@
                     /* sending msg failed*/
                     if (msg->easy_handle == ps->send_endpoint)
                     {
+#if DEBUG_CONNECTIONS
                       GNUNET_log(GNUNET_ERROR_TYPE_INFO,
                                  _("Connection %X: HTTP PUT to peer `%s' 
(`%s') failed: `%s' `%s'\n"),
                                  ps,
@@ -1158,7 +1184,7 @@
                                  http_plugin_address_to_string(NULL, ps->addr, 
ps->addrlen),
                                  "curl_multi_perform",
                                  curl_easy_strerror (msg->data.result));
-
+#endif
                       ps->send_connected = GNUNET_NO;
                       ps->send_active = GNUNET_NO;
                       
curl_multi_remove_handle(plugin->multi_handle,msg->easy_handle);
@@ -1171,6 +1197,7 @@
                     /* GET connection failed */
                     if (msg->easy_handle == ps->recv_endpoint)
                     {
+#if DEBUG_CONNECTIONS
                       GNUNET_log(GNUNET_ERROR_TYPE_INFO,
                            _("Connection %X: HTTP GET to peer `%s' (`%s') 
failed: `%s' `%s'\n"),
                            ps,
@@ -1178,6 +1205,7 @@
                            http_plugin_address_to_string(NULL, ps->addr, 
ps->addrlen),
                            "curl_multi_perform",
                            curl_easy_strerror (msg->data.result));
+#endif
                       ps->recv_connected = GNUNET_NO;
                       ps->recv_active = GNUNET_NO;
                       
curl_multi_remove_handle(plugin->multi_handle,msg->easy_handle);
@@ -1190,13 +1218,14 @@
                     if (msg->easy_handle == ps->send_endpoint)
                     {
                       GNUNET_assert (CURLE_OK == 
curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &http_result));
+#if DEBUG_CONNECTIONS
                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                                   "Connection %X: HTTP PUT connection to peer 
`%s' (`%s') was closed with HTTP code %u\n",
                                    ps,
                                    GNUNET_i2s(&pc->identity),
                                    http_plugin_address_to_string(NULL, 
ps->addr, ps->addrlen),
                                    http_result);
-
+#endif
                       /* Calling transmit continuation  */
                       cur_msg = ps->pending_msgs_tail;
                       if (( NULL != cur_msg) && (NULL != 
cur_msg->transmit_cont))
@@ -1219,13 +1248,14 @@
                     }
                     if (msg->easy_handle == ps->recv_endpoint)
                     {
+#if DEBUG_CONNECTIONS
                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                                   "Connection %X: HTTP GET connection to peer 
`%s' (`%s') was closed with HTTP code %u\n",
                                    ps,
                                    GNUNET_i2s(&pc->identity),
                                    http_plugin_address_to_string(NULL, 
ps->addr, ps->addrlen),
                                    http_result);
-
+#endif
                       ps->recv_connected = GNUNET_NO;
                       ps->recv_active = GNUNET_NO;
                       
curl_multi_remove_handle(plugin->multi_handle,msg->easy_handle);
@@ -1383,8 +1413,9 @@
     GNUNET_CONTAINER_multihashmap_put(plugin->peers, &pc->identity.hashPubKey, 
pc, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   }
   ps = get_Session(plugin, pc, addr, addrlen);
+
   /* session not existing, but address forced -> creating new session */
-  if ((ps==NULL) && (force_address == GNUNET_YES))
+  if ((force_address == GNUNET_YES) && (ps==NULL))
   {
     ps = GNUNET_malloc(sizeof (struct Session));
     ps->addr = GNUNET_malloc(addrlen);
@@ -1402,7 +1433,9 @@
   /* session not existing, address not forced -> looking for other session */
   if ((ps==NULL) && (force_address == GNUNET_NO))
   {
-    /* FIXME: CREATING SESSION, SHOULD CHOOSE EXISTING */
+    //struct PeerContext * tmp = pc->head;
+
+
     ps = GNUNET_malloc(sizeof (struct Session));
     ps->addr = GNUNET_malloc(addrlen);
     memcpy(ps->addr,addr,addrlen);

Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c   2010-07-06 12:25:33 UTC 
(rev 12172)
+++ gnunet/src/transport/test_plugin_transport_http.c   2010-07-06 12:45:34 UTC 
(rev 12173)
@@ -464,7 +464,6 @@
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message with max msg size 
succesfully sent!\n",fail_msgs_transmited_to_local_addrs);
     fail_msg_transmited_max_size = GNUNET_NO;
-    //shutdown_clean();
   }
 }
 
@@ -500,7 +499,7 @@
   if (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1)
   {
     fail_msg_transmited_max_size = GNUNET_NO;
-    //shutdown_clean();
+    shutdown_clean();
   }
 
   return GNUNET_TIME_UNIT_ZERO;
@@ -752,7 +751,7 @@
     return GNUNET_SYSERR;
   }
 #if DEBUG_CURL
-  curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
+  curl_easy_setopt(put_curl_handle, CURLOPT_VERBOSE, 1L);
 #endif
   curl_easy_setopt(curl_handle, CURLOPT_URL, url);
   curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L);
@@ -976,6 +975,7 @@
       memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
       api->send(api->cls, &my_identity, tmp, sizeof(struct 
GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, 
GNUNET_YES, &task_send_cont, &fail_msgs_transmited_to_local_addrs);
       tmp_addr = tmp_addr->next;
+
       count ++;
       type ++;
     }
@@ -984,6 +984,9 @@
 
   if (phase==2)
   {
+    /* disconnect from peer, so new connections are created */
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", 
GNUNET_i2s(&my_identity));
+    api->disconnect(api->cls, &my_identity);
 
     struct GNUNET_MessageHeader msg;
     char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));




reply via email to

[Prev in Thread] Current Thread [Next in Thread]