gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r12239 - gnunet/src/transport
Date: Fri, 16 Jul 2010 10:14:37 +0200

Author: wachs
Date: 2010-07-16 10:14:36 +0200 (Fri, 16 Jul 2010)
New Revision: 12239

Modified:
   gnunet/src/transport/plugin_transport_http.c
   gnunet/src/transport/test_plugin_transport_data_http.conf
Log:


Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-07-16 07:57:37 UTC 
(rev 12238)
+++ gnunet/src/transport/plugin_transport_http.c        2010-07-16 08:14:36 UTC 
(rev 12239)
@@ -40,9 +40,8 @@
 #include "microhttpd.h"
 #include <curl/curl.h>
 
-#define VERBOSE GNUNET_NO
+#define DEBUG_HTTP GNUNET_YES
 #define DEBUG_CURL GNUNET_NO
-#define DEBUG_HTTP GNUNET_NO
 #define DEBUG_CONNECTIONS GNUNET_NO
 #define DEBUG_SESSION_SELECTION GNUNET_NO
 
@@ -483,9 +482,9 @@
   struct Session * tmp = NULL;
   struct HTTP_Message * msg = NULL;
   struct HTTP_Message * msg_tmp = NULL;
-
+#if DEBUG_HTTP
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Freeing context for peer 
`%s'\n",GNUNET_i2s(&pc->identity));
-
+#endif
   while (ps!=NULL)
   {
        plugin->env->session_end(plugin, &pc->identity, ps);
@@ -638,14 +637,14 @@
   struct HTTP_PeerContext *pc = ps->peercontext;
   GNUNET_assert(ps != NULL);
   GNUNET_assert(pc != NULL);
-
+#if DEBUG_HTTP
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Connection %X: Forwarding message to transport service, type %u 
and size %u from `%s' (`%s')\n",
              ps,
              ntohs(message->type),
               ntohs(message->size),
              
GNUNET_i2s(&(ps->peercontext)->identity),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen));
-
+#endif
   pc->plugin->env->receive (ps->peercontext->plugin->env->cls,
                            &pc->identity,
                            message, 1, ps,
@@ -775,10 +774,12 @@
       response = MHD_create_response_from_data (strlen 
(HTTP_ERROR_RESPONSE),HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
       res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response);
       MHD_destroy_response (response);
+#if DEBUG_CONNECTIONS
       if (res == MHD_YES)
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer has no valid ident, sent 
HTTP 1.1/404\n");
       else
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Peer has no valid ident, could 
not send error\n");
+#endif
       return res;
     }
   }
@@ -862,12 +863,13 @@
     *httpSessionCache = ps;
     if (ps->msgtok==NULL)
       ps->msgtok = GNUNET_SERVER_mst_create (&mhd_write_mst_cb, ps);
-
+#if DEBUG_HTTP
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: HTTP Daemon has new an 
incoming `%s' request from peer `%s' (`%s')\n",
                 ps,
                 method,
                 GNUNET_i2s(&pc->identity),
                 http_plugin_address_to_string(NULL, ps->addr, ps->addrlen));
+#endif
   }
 
   /* Is it a PUT or a GET request */
@@ -1105,9 +1107,6 @@
       if (tmp[len-2] == 13)
         tmp[len-2]= '\0';
     }
-#if DEBUG_HTTP
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: `%s' %u \n",tmp, 
http_result);
-#endif
   }
   if (NULL != tmp)
     GNUNET_free (tmp);
@@ -1159,9 +1158,6 @@
       if (tmp[len-2] == 13)
         tmp[len-2]= '\0';
     }
-#if DEBUG_HTTP
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: `%s' %u \n",tmp, 
http_result);
-#endif
   }
   if (NULL != tmp)
     GNUNET_free (tmp);
@@ -1245,14 +1241,14 @@
   struct HTTP_PeerContext *pc = ps->peercontext;
   GNUNET_assert(ps != NULL);
   GNUNET_assert(pc != NULL);
-
+#if DEBUG_HTTP
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Connection %X: Forwarding message to transport service, type %u 
and size %u from `%s' (`%s')\n",
               ps,
               ntohs(message->type),
               ntohs(message->size),
               
GNUNET_i2s(&(pc->identity)),http_plugin_address_to_string(NULL,ps->addr,ps->addrlen));
-
+#endif
   pc->plugin->env->receive (pc->plugin->env->cls,
                             &pc->identity,
                             message, 1, ps,
@@ -1806,6 +1802,7 @@
 
   GNUNET_assert(cls !=NULL);
 
+#if DEBUG_HTTP
   char * force = GNUNET_malloc(40);
   if (force_address == GNUNET_YES)
     strcpy(force,"forced addr.");
@@ -1813,13 +1810,16 @@
     strcpy(force,"any addr.");
   if (force_address == GNUNET_SYSERR)
     strcpy(force,"reliable bi-direc. address addr.");
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Transport tells me to send %u bytes to 
`%s' using %s (%s) and session: %X\n",
                                       msgbuf_size,
                                       GNUNET_i2s(target),
                                       force,
                                       http_plugin_address_to_string(NULL, 
addr, addrlen),
                                       session);
+
   GNUNET_free(force);
+#endif
 
   pc = GNUNET_CONTAINER_multihashmap_get (plugin->peers, &target->hashPubKey);
   /* Peer unknown */
@@ -1841,11 +1841,12 @@
     if ((addr!=NULL) && (addrlen!=0))
     {
       ps = GNUNET_malloc(sizeof (struct Session));
+#if DEBUG_SESSION_SELECTION
       if (force_address == GNUNET_YES)
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection & forced 
address: creating new session %X to peer %s\n", ps, GNUNET_i2s(target));
       if (force_address != GNUNET_YES)
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection: creating 
new session %X to peer %s\n", ps, GNUNET_i2s(target));
-
+#endif
       if ((addrlen!=0) && (addr!=NULL))
       {
       ps->addr = GNUNET_malloc(addrlen);
@@ -1874,7 +1875,9 @@
     }
     else
     {
+#if DEBUG_HTTP
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing session found & and no 
address given: no way to send this message to peer `%s'!\n", 
GNUNET_i2s(target));
+#endif
       return GNUNET_SYSERR;
     }
   }
@@ -2192,8 +2195,10 @@
   if (plugin->multi_handle!=NULL)
   {
          mret = curl_multi_cleanup(plugin->multi_handle);
+#if DEBUG_HTTP
          if ( CURLM_OK != mret)
                GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"curl multihandle clean up 
failed\n");
+#endif
          plugin->multi_handle = NULL;
   }
   curl_global_cleanup();
@@ -2207,7 +2212,9 @@
   GNUNET_free_non_null (plugin->bind_address);
   GNUNET_free (plugin);
   GNUNET_free (api);
+#if DEBUG_HTTP
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Unload http plugin complete...\n");
+#endif
   return NULL;
 }
 
@@ -2226,7 +2233,9 @@
   char * hostname;
 
   GNUNET_assert(cls !=NULL);
+#if DEBUG_HTTP
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n");
+#endif
 
   plugin = GNUNET_malloc (sizeof (struct Plugin));
   plugin->stats = env->stats;
@@ -2255,8 +2264,7 @@
     {
       GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
                        "http",
-                       _
-                       ("Require valid port number for transport plugin `%s' 
in configuration!\n"),
+                       _("Require valid port number for transport plugin `%s' 
in configuration!\n"),
                        "transport-http");
       libgnunet_plugin_transport_http_done (api);
       return NULL;
@@ -2273,7 +2281,10 @@
                                                            &hostname));
       if (inet_aton(hostname, plugin->bind_address)==0)
       {
-         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"Misconfigured address to bind to 
in configuration\n");
+          GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
+                           "http",
+                           _("Misconfigured address to bind to in 
configuration!\n"),
+                           "transport-http");
          GNUNET_free(plugin->bind_address);
          plugin->bind_address = NULL;
       }
@@ -2285,7 +2296,7 @@
   if ((plugin->http_server_daemon_v4 == NULL) && 
(plugin->http_server_daemon_v6 == NULL) && (port != 0))
     {
     plugin->http_server_daemon_v6 = MHD_start_daemon (
-#if DEBUG_HTTP
+#if DEBUG_CONNECTIONS
                                                                   
MHD_USE_DEBUG |
 #endif
                                                                   MHD_USE_IPv6,
@@ -2300,7 +2311,7 @@
                                        MHD_OPTION_END);
 
     plugin->http_server_daemon_v4 = MHD_start_daemon (
-#if DEBUG_HTTP
+#if DEBUG_CONNECTIONS
                                                                   
MHD_USE_DEBUG |
 #endif
                                                                   MHD_NO_FLAG,
@@ -2320,13 +2331,24 @@
   if (plugin->http_server_daemon_v6 != NULL)
     plugin->http_server_task_v6 = http_server_daemon_prepare (plugin, 
plugin->http_server_daemon_v6);
 
+
   if (plugin->http_server_task_v4 != GNUNET_SCHEDULER_NO_TASK)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port 
%u\n",port);
+  {
+#if DEBUG_HTTP
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port 
%u\n",port);
+#endif
+  }
   else if (plugin->http_server_task_v6 != GNUNET_SCHEDULER_NO_TASK)
+  {
+#if DEBUG_HTTP
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 and IPv6 on 
port %u\n",port);
+#endif
+  }
   else
   {
+#if DEBUG_HTTP
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No MHD was started, transport plugin 
not functional!\n");
+#endif
     libgnunet_plugin_transport_http_done (api);
     return NULL;
   }
@@ -2338,9 +2360,9 @@
   if ( NULL == plugin->multi_handle )
   {
     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
-                     "http",
-                     _("Could not initialize curl multi handle, failed to 
start http plugin!\n"),
-                     "transport-http");
+                                  "http",
+                                  _("Could not initialize curl multi handle, 
failed to start http plugin!\n"),
+                                  "transport-http");
     libgnunet_plugin_transport_http_done (api);
     return NULL;
   }

Modified: gnunet/src/transport/test_plugin_transport_data_http.conf
===================================================================
--- gnunet/src/transport/test_plugin_transport_data_http.conf   2010-07-16 
07:57:37 UTC (rev 12238)
+++ gnunet/src/transport/test_plugin_transport_data_http.conf   2010-07-16 
08:14:36 UTC (rev 12239)
@@ -12,7 +12,7 @@
 
 [transport]
 PREFIX = valgrind --leak-check=full
-DEBUG = NO
+DEBUG = YES
 
 [statistics]
 ACCEPT_FROM6 = ::1;




reply via email to

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