- use proper signedness
[oweals/gnunet.git] / src / transport / plugin_transport_tcp.c
index 99272991146c2db137fa74ae1d07c6d48ff412ae..04fac9cdecd841ec540d8438af85946616fa9bc5 100644 (file)
@@ -1285,7 +1285,6 @@ tcp_plugin_send (void *cls,
                                                     session))
   {
     GNUNET_assert (session->client != NULL);
-    reschedule_session_timeout (session);
     GNUNET_SERVER_client_set_timeout (session->client,
                                       GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
     GNUNET_STATISTICS_update (plugin->env->stats,
@@ -1304,7 +1303,6 @@ tcp_plugin_send (void *cls,
     LOG (GNUNET_ERROR_TYPE_DEBUG,
         "This NAT WAIT session for peer `%s' is not yet ready!\n",
         GNUNET_i2s (&session->target));
-    reschedule_session_timeout (session);
     GNUNET_STATISTICS_update (plugin->env->stats,
                               gettext_noop ("# bytes currently in TCP buffers"),
                               msgbuf_size, GNUNET_NO);
@@ -1420,6 +1418,18 @@ nat_connect_timeout (void *cls,
                           session);
 }
 
+static void
+tcp_plugin_update_session_timeout (void *cls,
+                                  const struct GNUNET_PeerIdentity *peer,
+                                  struct Session *session)
+{
+  struct Plugin *plugin = cls;
+  if (GNUNET_SYSERR == find_session (plugin, session))
+    return;
+
+  reschedule_session_timeout (session);
+}
+
 
 /**
  * Create a new session to transmit data to the target
@@ -1896,7 +1906,7 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type,
     asc (asc_cls, NULL);
     return;
   }
-  ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext));
+  ppc = GNUNET_new (struct PrettyPrinterContext);
   if (addrlen == sizeof (struct IPv6TcpAddress))
     ppc->ipv6 = GNUNET_YES;
   else
@@ -2514,7 +2524,7 @@ try_connection_reversal (void *cls, const struct sockaddr *addr,
 
   /* FIXME: do we need to track these probe context objects so that
    * we can clean them up on plugin unload? */
-  tcp_probe_ctx = GNUNET_malloc (sizeof (struct TCPProbeContext));
+  tcp_probe_ctx = GNUNET_new (struct TCPProbeContext);
   tcp_probe_ctx->message.header.size =
       htons (sizeof (struct TCP_NAT_ProbeMessage));
   tcp_probe_ctx->message.header.type =
@@ -2687,6 +2697,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
   api->address_to_string = &tcp_address_to_string;
   api->string_to_address = &tcp_string_to_address;
   api->get_network = &tcp_get_network;
+  api->update_session_timeout = &tcp_plugin_update_session_timeout;
   plugin->service = service;
   if (NULL != service)
   {