gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r17013 - gnunet/src/transport
Date: Mon, 26 Sep 2011 15:35:28 +0200

Author: wachs
Date: 2011-09-26 15:35:28 +0200 (Mon, 26 Sep 2011)
New Revision: 17013

Modified:
   gnunet/src/transport/plugin_transport_http.h
   gnunet/src/transport/plugin_transport_http_client.c
   gnunet/src/transport/plugin_transport_http_new.c
   gnunet/src/transport/plugin_transport_http_server.c
Log:
removing incoherent address formats
cleaning up logging


Modified: gnunet/src/transport/plugin_transport_http.h
===================================================================
--- gnunet/src/transport/plugin_transport_http.h        2011-09-26 12:24:41 UTC 
(rev 17012)
+++ gnunet/src/transport/plugin_transport_http.h        2011-09-26 13:35:28 UTC 
(rev 17013)
@@ -249,7 +249,7 @@
   void *server_recv;
   void *server_send;
   struct GNUNET_TIME_Absolute delay;
-  GNUNET_SCHEDULER_TaskIdentifier reset_task;
+  GNUNET_SCHEDULER_TaskIdentifier recv_wakeup_task;
   uint32_t tag;
 
 };

Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2011-09-26 12:24:41 UTC 
(rev 17012)
+++ gnunet/src/transport/plugin_transport_http_client.c 2011-09-26 13:35:28 UTC 
(rev 17013)
@@ -51,7 +51,11 @@
       text[size] = '\n';
       text[size + 1] = '\0';
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client: %X - %s", cls, text);
+#if BUILD_HTTPS
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-https", "Client: %X - 
%s", cls, text);
+#else
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-http", "Client: %X - 
%s", cls, text);
+#endif
   }
   return 0;
 }
@@ -61,6 +65,8 @@
 client_send (struct Session *s, struct HTTP_Message *msg)
 {
   GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg);
+  if (s != NULL)
+    curl_easy_pause(s->client_put, CURLPAUSE_CONT);
   return GNUNET_OK;
 }
 
@@ -183,7 +189,7 @@
        {
 #if DEBUG_HTTP
          GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
-                   "Connection to '%s'  %s ended\n", GNUNET_i2s(&s->target), 
GNUNET_a2s (s->addr, s->addrlen));
+                   "Client: %X connection to '%s'  %s ended\n", s, 
GNUNET_i2s(&s->target), GNUNET_a2s (s->addr, s->addrlen));
 #endif
          client_disconnect(s);
          //GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,"Notifying 
about ended session to peer `%s' `%s'\n", GNUNET_i2s (&s->target), 
http_plugin_address_to_string (plugin, s->addr, s->addrlen));
@@ -210,7 +216,8 @@
 
 #if DEBUG_HTTP
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
-                   "Client: Deleting outbound PUT session to peer `%s'\n",
+                   "Client: %X Deleting outbound PUT session to peer `%s'\n",
+                   s,
                    GNUNET_i2s (&s->target));
 #endif
 
@@ -229,9 +236,15 @@
 
 #if DEBUG_HTTP
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
-                   "Client: Deleting outbound GET session to peer `%s'\n",
+                   "Client: %X Deleting outbound GET session to peer `%s'\n",
+                   s,
                    GNUNET_i2s (&s->target));
 #endif
+  if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
+  {
+   GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
+   s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
+  }
 
   if (s->client_get != NULL)
   {
@@ -290,7 +303,19 @@
 #endif
   }
 }
+static void
+client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  struct Session *s = cls;
 
+  s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
+  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
+    return;
+
+  if (s->client_get != NULL)
+    curl_easy_pause(s->client_get, CURLPAUSE_CONT);
+}
+
 /**
 * Callback method used with libcurl
 * Method is called when libcurl needs to write data during sending
@@ -305,6 +330,7 @@
 {
   struct Session *s = cls;
   struct Plugin *plugin = s->plugin;
+  struct GNUNET_TIME_Absolute now;
 
 #if VERBOSE_CLIENT
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received 
%Zu bytes from peer `%s'\n",
@@ -312,14 +338,21 @@
                    GNUNET_i2s (&s->target));
 #endif
 
-  if (GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value)
+  now = GNUNET_TIME_absolute_get();
+  if (now.abs_value < s->delay.abs_value)
   {
 #if DEBUG_CLIENT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "no inbound bandwidth available! Next read was delayed for  
%llu ms\n",
+                "No inbound bandwidth available! Next read was delayed for  
%llu ms\n",
                 s, GNUNET_TIME_absolute_get_difference(s->delay, 
GNUNET_TIME_absolute_get()).rel_value);
 #endif
-    return 0;
+    if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
+    {
+      GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
+      s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
+    }
+    s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed( 
GNUNET_TIME_absolute_get_difference(s->delay, now), &client_wake_up, s);
+    return CURLPAUSE_ALL;
   }
 
 
@@ -345,7 +378,7 @@
 client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
 {
   struct Session *s = cls;
-  //struct Plugin *plugin = s->plugin;
+  struct Plugin *plugin = s->plugin;
   size_t bytes_sent = 0;
   size_t len;
 
@@ -394,9 +427,9 @@
   if (msg->pos == msg->size)
   {
 #if VERBOSE_CLIENT
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Message with %u bytes sent, removing message from queue\n",
-                s, msg->pos);
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                "Client: %X Message with %u bytes sent, removing message from 
queue\n",
+                s, msg->size, msg->pos);
 #endif
     /* Calling transmit continuation  */
     if (NULL != msg->transmit_cont)
@@ -426,7 +459,6 @@
   plugin->last_tag++;
   /* create url */
   GNUNET_asprintf (&url, "%s%s;%u", http_plugin_address_to_string (plugin, 
s->addr, s->addrlen), GNUNET_h2s_full 
(&plugin->env->my_identity->hashPubKey),plugin->last_tag);
-  //GNUNET_asprintf (&url, "http://www.heise.de";, 
http_plugin_address_to_string (plugin, s->addr, s->addrlen), GNUNET_h2s_full 
(&plugin->env->my_identity->hashPubKey),plugin->last_tag);
 #if 0
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
                    "URL `%s'\n",

Modified: gnunet/src/transport/plugin_transport_http_new.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_new.c    2011-09-26 12:24:41 UTC 
(rev 17012)
+++ gnunet/src/transport/plugin_transport_http_new.c    2011-09-26 13:35:28 UTC 
(rev 17013)
@@ -34,22 +34,6 @@
 #define LEARNED_ADDRESS_EXPIRATION GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_HOURS, 6)
 
 /**
- * Network format for IPv4 addresses.
- */
-struct IPv4HttpAddress
-{
-  /**
-   * IPv4 address, in network byte order.
-   */
-  uint32_t ipv4_addr GNUNET_PACKED;
-
-  /**
-   * Port number, in network byte order.
-   */
-  uint16_t port GNUNET_PACKED;
-};
-
-/**
  * Wrapper to manage IPv4 addresses
  */
 struct IPv4HttpAddressWrapper
@@ -64,27 +48,10 @@
    */
   struct IPv4HttpAddressWrapper *prev;
 
-  struct IPv4HttpAddress *addr;
+  struct sockaddr_in addr;
 };
 
 /**
- * Network format for IPv6 addresses.
- */
-struct IPv6HttpAddress
-{
-  /**
-   * IPv6 address.
-   */
-  struct in6_addr ipv6_addr GNUNET_PACKED;
-
-  /**
-   * Port number, in network byte order.
-   */
-  uint16_t port GNUNET_PACKED;
-
-};
-
-/**
  * Wrapper for IPv4 addresses.
  */
 struct IPv6HttpAddressWrapper
@@ -99,7 +66,10 @@
    */
   struct IPv6HttpAddressWrapper *prev;
 
-  struct IPv6HttpAddress *addr;
+  /**
+   * IPv6 address.
+   */
+  struct sockaddr_in6 addr GNUNET_PACKED;
 };
 
 
@@ -188,33 +158,20 @@
   struct PrettyPrinterContext *ppc;
   const void *sb;
   size_t sbs;
-  struct sockaddr_in a4;
-  struct sockaddr_in6 a6;
-  const struct IPv4HttpAddress *t4;
-  const struct IPv6HttpAddress *t6;
-  uint16_t port;
+  uint16_t port = 0 ;
 
-  if (addrlen == sizeof (struct IPv6HttpAddress))
+  if (addrlen == sizeof (struct sockaddr_in6))
   {
-    t6 = addr;
-    memset (&a6, 0, sizeof (a6));
-    a6.sin6_family = AF_INET6;
-    a6.sin6_port = t6->port;
-    memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
-    port = ntohs (t6->port);
-    sb = &a6;
-    sbs = sizeof (a6);
+    sb = addr;
+    sbs = sizeof (struct sockaddr_in6);
+
+    port = ntohs (((struct sockaddr_in6 *)addr)->sin6_port);
   }
-  else if (addrlen == sizeof (struct IPv4HttpAddress))
+  else if (addrlen == sizeof (struct sockaddr_in))
   {
-    t4 = addr;
-    memset (&a4, 0, sizeof (a4));
-    a4.sin_family = AF_INET;
-    a4.sin_port = t4->port;
-    a4.sin_addr.s_addr = t4->ipv4_addr;
-    port = ntohs (t4->ipv4_addr);
-    sb = &a4;
-    sbs = sizeof (a4);
+    sb = &addr;
+    sbs = sizeof (struct sockaddr_in);
+    port = ntohs (((struct sockaddr_in *)addr)->sin_port);
   }
   else
   {
@@ -248,23 +205,21 @@
 static int
 http_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
 {
+
   struct Plugin *plugin = cls;
-  struct IPv4HttpAddress *v4;
-  struct IPv6HttpAddress *v6;
   struct IPv4HttpAddressWrapper *w_tv4 = plugin->ipv4_addr_head;
   struct IPv6HttpAddressWrapper *w_tv6 = plugin->ipv6_addr_head;
 
   GNUNET_assert (cls != NULL);
-  if ((addrlen != sizeof (struct IPv4HttpAddress)) &&
-      (addrlen != sizeof (struct IPv6HttpAddress)))
+  if ((addrlen != sizeof (struct sockaddr_in)) ||
+      (addrlen != sizeof (struct sockaddr_in6)))
     return GNUNET_SYSERR;
-  if (addrlen == sizeof (struct IPv4HttpAddress))
+
+  if (addrlen == sizeof (struct sockaddr_in))
   {
-    v4 = (struct IPv4HttpAddress *) addr;
     while (w_tv4 != NULL)
     {
-      if (0 ==
-          memcmp (&w_tv4->addr->ipv4_addr, &v4->ipv4_addr, sizeof (uint32_t)))
+      if (0 == memcmp (&w_tv4->addr, addr, sizeof (struct sockaddr_in)))
         break;
       w_tv4 = w_tv4->next;
     }
@@ -273,14 +228,13 @@
     else
       return GNUNET_SYSERR;
   }
-  if (addrlen == sizeof (struct IPv6HttpAddress))
+  if (addrlen == sizeof (struct sockaddr_in6))
   {
-    v6 = (struct IPv6HttpAddress *) addr;
     while (w_tv6 != NULL)
     {
       if (0 ==
-          memcmp (&w_tv6->addr->ipv6_addr, &v6->ipv6_addr,
-                  sizeof (struct in6_addr)))
+          memcmp (&w_tv6->addr, addr,
+                  sizeof (struct sockaddr_in6)))
         break;
       w_tv6 = w_tv6->next;
     }
@@ -289,7 +243,7 @@
     else
       return GNUNET_SYSERR;
   }
-  return GNUNET_SYSERR;
+  return GNUNET_OK;
 }
 
 struct GNUNET_TIME_Relative
@@ -327,30 +281,27 @@
 const char *
 http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
 {
-  const struct IPv4HttpAddress *t4;
-  const struct IPv6HttpAddress *t6;
-  struct sockaddr_in a4;
-  struct sockaddr_in6 a6;
+
+  struct sockaddr_in *a4;
+  struct sockaddr_in6 *a6;
   char *address;
   static char rbuf[INET6_ADDRSTRLEN + 13];
   uint16_t port;
   int res = 0;
 
-  if (addrlen == sizeof (struct IPv6HttpAddress))
+  if (addrlen == sizeof (struct sockaddr_in6))
   {
+    a6 = (struct sockaddr_in6 *) addr;
     address = GNUNET_malloc (INET6_ADDRSTRLEN);
-    t6 = addr;
-    a6.sin6_addr = t6->ipv6_addr;
-    inet_ntop (AF_INET6, &(a6.sin6_addr), address, INET6_ADDRSTRLEN);
-    port = ntohs (t6->port);
+    inet_ntop (AF_INET6, &(a6->sin6_addr), address, INET6_ADDRSTRLEN);
+    port = ntohs (a6->sin6_port);
   }
-  else if (addrlen == sizeof (struct IPv4HttpAddress))
+  else if (addrlen == sizeof (struct sockaddr_in))
   {
+    a4 = (struct sockaddr_in *) addr;
     address = GNUNET_malloc (INET_ADDRSTRLEN);
-    t4 = addr;
-    a4.sin_addr.s_addr = t4->ipv4_addr;
-    inet_ntop (AF_INET, &(a4.sin_addr), address, INET_ADDRSTRLEN);
-    port = ntohs (t4->port);
+    inet_ntop (AF_INET, &(a4->sin_addr), address, INET_ADDRSTRLEN);
+    port = ntohs (a4->sin_port);
   }
   else
   {
@@ -364,9 +315,9 @@
 #endif
 
   GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13));
-  if (addrlen == sizeof (struct IPv6HttpAddress))  
+  if (addrlen == sizeof (struct sockaddr_in6))
     res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/", protocol, 
address, port);
-  else if (addrlen == sizeof (struct IPv4HttpAddress))
+  else if (addrlen == sizeof (struct sockaddr_in))
     res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/", protocol, 
address, port);
 
   GNUNET_free (address);
@@ -392,11 +343,6 @@
     e_peer = GNUNET_NO;
     e_addr = GNUNET_NO;
 
-#if DEBUG_HTTP
-  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                   "Comparing session %X <-> %X\n", session, t);
-#endif
-
     if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity)))
     {
       e_peer = GNUNET_YES;
@@ -409,32 +355,16 @@
       }
       if ((t == session))
       {
-#if DEBUG_HTTP
-  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                   "Session %X: %s: \n", t, GNUNET_a2s (t->addr, t->addrlen));
-  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                   "Session %X: %s: \n", session, GNUNET_a2s (session->addr, 
session->addrlen));
-
-#endif
        if(t->addrlen == session->addrlen)
        {
-         GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                          "length ok\n");
         if (0 == memcmp (session->addr, t->addr, t->addrlen))
         {
-          GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                           "equal\n");
           e_addr = GNUNET_YES;
         }
        }
       }
     }
 
-#if DEBUG_HTTP
-  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                   "Session %X: E_PEER YES : %i E_ADDR: %i force %u: \n", t, 
e_peer, e_addr, force_address);
-#endif
-
     if ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO))
     {
       s = t;
@@ -443,10 +373,6 @@
     if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == 
GNUNET_YES))
     {
       s = t;
-#if DEBUG_HTTP
-  GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                   "Session %X: HERE!\n", t, e_addr, s);
-#endif
       break;
     }
     if ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR))
@@ -557,7 +483,7 @@
 #if DEBUG_HTTP
   GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
                    "Sending %u bytes to peer `%s' on address `%s' %X %i\n", 
msgbuf_size,
-                   GNUNET_i2s (target), GNUNET_a2s (addr, addrlen), session, 
force_address);
+                   GNUNET_i2s (target), ((addr != NULL) && (addrlen != 0)) ? 
http_plugin_address_to_string(plugin, addr, addrlen) : "<inbound>", session, 
force_address);
 #endif
 
   struct Session *s = NULL;
@@ -613,7 +539,7 @@
   {
 #if DEBUG_HTTP
     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                     "Using client session to send to `%s'\n",
+                     "Using outbound client session to send to `%s'\n",
                      GNUNET_i2s (target));
 #endif
      client_send (s, msg);
@@ -625,7 +551,7 @@
     res = msgbuf_size;
 #if DEBUG_HTTP
     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
-                     "Using server session to send to `%s'\n",
+                     "Using inbound server session to send to `%s'\n",
                      GNUNET_i2s (target));
 #endif
 
@@ -670,9 +596,7 @@
                  socklen_t addrlen)
 {
   struct Plugin *plugin = cls;
-  struct IPv4HttpAddress *t4 = NULL;
   struct IPv4HttpAddressWrapper *w_t4 = NULL;
-  struct IPv6HttpAddress *t6 = NULL;
   struct IPv6HttpAddressWrapper *w_t6 = NULL;
   int af;
 
@@ -683,9 +607,9 @@
     w_t4 = plugin->ipv4_addr_head;
     while (w_t4 != NULL)
     {
-      int res = memcmp (&w_t4->addr->ipv4_addr,
-                        &((struct sockaddr_in *) addr)->sin_addr,
-                        sizeof (struct in_addr));
+      int res = memcmp (&w_t4->addr,
+                        (struct sockaddr_in *) addr,
+                        sizeof (struct sockaddr_in));
 
       if (0 == res)
         break;
@@ -694,27 +618,27 @@
     if (w_t4 == NULL)
     {
       w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper));
-      t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress));
-      memcpy (&t4->ipv4_addr, &((struct sockaddr_in *) addr)->sin_addr,
-              sizeof (struct in_addr));
-      t4->port = htons (plugin->port);
+      memcpy (&w_t4->addr, (struct sockaddr_in *) addr,
+              sizeof (struct sockaddr_in));
 
-      w_t4->addr = t4;
-
       GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head,
                                    plugin->ipv4_addr_tail, w_t4);
     }
-    plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr,
-                                 sizeof (struct IPv4HttpAddress));
+#if DEBUG_HTTP
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Notifying transport to add IPv4 address `%s'\n",
+                     http_plugin_address_to_string(NULL, &w_t4->addr, sizeof 
(struct sockaddr_in)));
+#endif
+    plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr, 
sizeof (struct sockaddr_in));
 
     break;
   case AF_INET6:
     w_t6 = plugin->ipv6_addr_head;
     while (w_t6)
     {
-      int res = memcmp (&w_t6->addr->ipv6_addr,
-                        &((struct sockaddr_in6 *) addr)->sin6_addr,
-                        sizeof (struct in6_addr));
+      int res = memcmp (&w_t6->addr,
+                        (struct sockaddr_in6 *) addr,
+                        sizeof (struct sockaddr_in6));
 
       if (0 == res)
         break;
@@ -723,19 +647,18 @@
     if (w_t6 == NULL)
     {
       w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper));
-      t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress));
+      memcpy (&w_t6->addr, (struct sockaddr_in6 *) addr,
+              sizeof (struct sockaddr_in6));
 
-      memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr,
-              sizeof (struct in6_addr));
-      t6->port = htons (plugin->port);
-
-      w_t6->addr = t6;
-
       GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head,
                                    plugin->ipv6_addr_tail, w_t6);
     }
-    plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr,
-                                 sizeof (struct IPv6HttpAddress));
+#if DEBUG_HTTP
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Notifying transport to add IPv6 address `%s'\n",
+                     http_plugin_address_to_string(NULL, &w_t6->addr, sizeof 
(struct sockaddr_in)));
+#endif
+    plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr, 
sizeof (struct sockaddr_in6));
     break;
   default:
     return;
@@ -759,7 +682,7 @@
     w_t4 = plugin->ipv4_addr_head;
     while (w_t4 != NULL)
     {
-      int res = memcmp (&w_t4->addr->ipv4_addr,
+      int res = memcmp (&(w_t4->addr.sin_addr),
                         &((struct sockaddr_in *) addr)->sin_addr,
                         sizeof (struct in_addr));
 
@@ -769,19 +692,24 @@
     }
     if (w_t4 == NULL)
       return;
-    plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr,
-                                 sizeof (struct IPv4HttpAddress));
 
+#if DEBUG_HTTP
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Notifying transport to remove IPv4 address `%s'\n",
+                     http_plugin_address_to_string(NULL, &w_t4->addr, sizeof 
(struct sockaddr_in)));
+#endif
+    plugin->env->notify_address (plugin->env->cls, add_remove, &w_t4->addr,
+                                 sizeof (struct sockaddr_in));
+
     GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, 
plugin->ipv4_addr_tail,
                                  w_t4);
-    GNUNET_free (w_t4->addr);
     GNUNET_free (w_t4);
     break;
   case AF_INET6:
     w_t6 = plugin->ipv6_addr_head;
     while (w_t6 != NULL)
     {
-      int res = memcmp (&w_t6->addr->ipv6_addr,
+      int res = memcmp (&(w_t6->addr.sin6_addr),
                         &((struct sockaddr_in6 *) addr)->sin6_addr,
                         sizeof (struct in6_addr));
 
@@ -791,12 +719,16 @@
     }
     if (w_t6 == NULL)
       return;
-    plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr,
-                                 sizeof (struct IPv6HttpAddress));
+#if DEBUG_HTTP
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Notifying transport to remove IPv6 address `%s'\n",
+                     http_plugin_address_to_string(NULL, &w_t4->addr, sizeof 
(struct sockaddr_in)));
+#endif
+    plugin->env->notify_address (plugin->env->cls, add_remove, &w_t6->addr,
+                                 sizeof (struct sockaddr_in6 ));
 
     GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, 
plugin->ipv6_addr_tail,
                                  w_t6);
-    GNUNET_free (w_t6->addr);
     GNUNET_free (w_t6);
     break;
   default:
@@ -820,7 +752,7 @@
 {
   GNUNET_assert (cls != NULL);
   struct Plugin *plugin = cls;
-  static int limit;
+  //static int limit;
 #if DEBUG_HTTP
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
                    "NPMC called %s to address `%s'\n",
@@ -832,9 +764,9 @@
   {
   case GNUNET_YES:
     // FIXME DEBUGGING
-    if (limit < 1)
+    //if (limit < 1)
       nat_add_address (cls, add_remove, addr, addrlen);
-    limit++;
+    //limit++;
     // FIXME END
     break;
   case GNUNET_NO:
@@ -895,7 +827,6 @@
     w_t4 = plugin->ipv4_addr_head;
     GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, 
plugin->ipv4_addr_tail,
                                  w_t4);
-    GNUNET_free (w_t4->addr);
     GNUNET_free (w_t4);
   }
 
@@ -904,7 +835,6 @@
     w_t6 = plugin->ipv6_addr_head;
     GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, 
plugin->ipv6_addr_tail,
                                  w_t6);
-    GNUNET_free (w_t6->addr);
     GNUNET_free (w_t6);
   }
 }

Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2011-09-26 12:24:41 UTC 
(rev 17012)
+++ gnunet/src/transport/plugin_transport_http_server.c 2011-09-26 13:35:28 UTC 
(rev 17013)
@@ -270,6 +270,7 @@
 server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
 {
   struct Session *s = cls;
+  struct Plugin *plugin = s->plugin;
   struct HTTP_Message *msg;
   int bytes_read = 0;
   //static int c = 0;
@@ -301,8 +302,9 @@
   }
 
 #if VERBOSE_CLIENT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: MHD has sent %u 
bytes\n",
-              s, bytes_read);
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                   "Server: %X: sent %u bytes\n",
+                   s, bytes_read);
 #endif
   return bytes_read;
 }
@@ -372,7 +374,8 @@
     plugin->cur_connections++;
 
 #if VERBOSE_SERVER
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: New inbound connection from 
%s with tag %u\n", GNUNET_i2s(&target), tag);
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Server: New inbound connection from %s with tag %u\n", 
GNUNET_i2s(&target), tag);
 #endif
     /* find duplicate session */
 
@@ -389,7 +392,8 @@
     if (t != NULL)
     {
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate session, 
dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                       "Server: Duplicate session, dismissing new connection 
from peer `%s'\n", GNUNET_i2s (&target));
 #endif
       goto error;
     }
@@ -412,13 +416,15 @@
       goto create;
 
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found existing 
semi-session for `%s'\n", GNUNET_i2s (&target));
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Server: Found existing semi-session for `%s'\n", 
GNUNET_i2s (&target));
 #endif
 
     if ((direction == _SEND) && (t->server_send != NULL))
     {
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate GET session, 
dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                       "Server: Duplicate GET session, dismissing new 
connection from peer `%s'\n", GNUNET_i2s (&target));
 #endif
       goto error;
     }
@@ -428,7 +434,8 @@
       GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, 
plugin->server_semi_tail, s);
       GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found matching 
semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target));
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                       "Server: Found matching semi-session, merging session 
for peer `%s'\n", GNUNET_i2s (&target));
 #endif
 
       goto found;
@@ -436,7 +443,8 @@
     if ((direction == _RECEIVE) && (t->server_recv != NULL))
     {
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Duplicate PUT session, 
dismissing new connection from peer `%s'\n", GNUNET_i2s (&target));
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                       "Server: Duplicate PUT session, dismissing new 
connection from peer `%s'\n", GNUNET_i2s (&target));
 #endif
       goto error;
     }
@@ -446,7 +454,8 @@
       GNUNET_CONTAINER_DLL_remove(plugin->server_semi_head, 
plugin->server_semi_tail, s);
       GNUNET_CONTAINER_DLL_insert(plugin->head, plugin->tail, s);
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Found matching 
semi-session, merging session for peer `%s'\n", GNUNET_i2s (&target));
+      GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                       "Server: Found matching semi-session, merging session 
for peer `%s'\n", GNUNET_i2s (&target));
 #endif
       goto found;
     }
@@ -454,10 +463,11 @@
 create:
 /* create new session */
 #if VERBOSE_SERVER
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server: Creating new session for 
peer `%s' \n", GNUNET_i2s (&target));
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                 "Server: Creating new session for peer `%s' \n", GNUNET_i2s 
(&target));
 #endif
 
-    s = create_session(plugin,
+    s = create_session (plugin,
                         &target,
                         conn_info->client_addr,
                         addrlen,
@@ -474,7 +484,10 @@
 
     goto found;
 error:
-        GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Invalid connection 
request\n");
+#if VERBOSE_SERVER
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                 "Server: Invalid connection request\n");
+#endif
         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);
@@ -490,8 +503,11 @@
       s->server_recv = sc;
 
     int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000);
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Server: Setting Timeout to %u\n", 
to);
-    //MHD_set_connection_option (mhd_connection, 
MHD_CONNECTION_OPTION_TIMEOUT, to);
+#if VERBOSE_SERVER
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                     "Server: Setting Timeout to %u\n", to);
+#endif
+    MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, 
to);
 
     (*httpSessionCache) = sc;
   }
@@ -529,7 +545,7 @@
     {
 #if VERBOSE_SERVER
   GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
-                   "Server: peer `%s' PUT on address `%s' connected\n",
+                   "Server: Peer `%s' PUT on address `%s' connected\n",
                    GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen));
 #endif
       return MHD_YES;
@@ -545,17 +561,18 @@
 #endif
       if ((GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value))
       {
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "Connection %X: PUT with %u bytes forwarded to MST\n", s,
+#if VERBOSE_SERVER
+        GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                    "Server: %X: PUT with %u bytes forwarded to MST\n", s,
                     *upload_data_size);
-
+#endif
         if (s->msg_tk == NULL)
         {
           s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s);
         }
         res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, 
*upload_data_size, GNUNET_NO, GNUNET_NO);
-        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                    "Server: Received %Zu bytes\n",
+        GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+                         "Server: Received %Zu bytes\n",
                     *upload_data_size);
         (*upload_data_size) = 0;
       }
@@ -652,7 +669,7 @@
     t = t->next;
   }
   plugin->cur_connections--;
-
+/*
   if (plugin->server_v4_task != GNUNET_SCHEDULER_NO_TASK)
   {
     GNUNET_SCHEDULER_cancel(plugin->server_v4_task);
@@ -666,7 +683,7 @@
      plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK;
    }
    plugin->server_v6_task = server_schedule (plugin, plugin->server_v6);
-
+*/
   if ((s->server_send == NULL) && (s->server_recv == NULL))
   {
 #if VERBOSE_SERVER




reply via email to

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