stuff
[oweals/gnunet.git] / src / transport / plugin_transport_tcp.c
index 2a5cfaa8d82054e452f5af5fcb08dd1963784470..e796dacf4ffe20cce4c1a2427ca7ca744153bda0 100644 (file)
@@ -1113,6 +1113,7 @@ tcp_plugin_send (void *cls,
                                     target,
                                     NULL, 
                                    GNUNET_YES);
+          GNUNET_assert (session != NULL);
 
           /* create new message entry */
           pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
@@ -1189,9 +1190,22 @@ tcp_plugin_send (void *cls,
              addrlen);
       session->connect_alen = addrlen;
     }
+  else  /* session != NULL */
+    {
+      /* check if session is valid */
+      struct Session * ses = plugin->sessions;
+      while ((ses != NULL) && (ses != session))
+        ses = ses->next;
+      if (ses == NULL)
+       {
+         GNUNET_break (0);
+         return -1;
+       }
+    }
   GNUNET_assert (session != NULL);
   GNUNET_assert (session->client != NULL);
 
+
   GNUNET_SERVER_client_set_timeout(session->client, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
   GNUNET_STATISTICS_update (plugin->env->stats,
                            gettext_noop ("# bytes currently in TCP buffers"),
@@ -1293,16 +1307,6 @@ struct PrettyPrinterContext
    */
   void *asc_cls;
 
-  /**
-   * The address
-   */
-  void * addr;
-
-  /**
-   * address length
-   */
-  size_t addr_len;
-
   /**
    * Port to add after the IP address.
    */
@@ -1324,9 +1328,7 @@ append_port (void *cls, const char *hostname)
 
   if (hostname == NULL)
     {
-      ret = strdup(tcp_address_to_string(NULL, ppc->addr, ppc->addr_len));
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error in name resolution: `%s'\n",ret);
-      ppc->asc (ppc->asc_cls, ret);
+      ppc->asc (ppc->asc_cls, NULL);
       GNUNET_free (ppc);
       return;
     }
@@ -1400,13 +1402,10 @@ tcp_plugin_address_pretty_printer (void *cls,
       asc (asc_cls, NULL);
       return;
     }
-  ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext) + addrlen);
+  ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext));
   ppc->asc = asc;
   ppc->asc_cls = asc_cls;
   ppc->port = port;
-  ppc->addr = &ppc[1];
-  ppc->addr_len = addrlen;
-  memcpy(ppc->addr, addr, addrlen);
   GNUNET_RESOLVER_hostname_get (sb,
                                 sbs,
                                 !numeric, timeout, &append_port, ppc);