*/
#include "platform.h"
#include "gnunet_hello_lib.h"
+#include "gnunet_constants.h"
#include "gnunet_connection_lib.h"
#include "gnunet_container_lib.h"
#include "gnunet_nat_lib.h"
#define DEBUG_TCP_NAT GNUNET_NO
-
/**
* Initial handshake message for a session.
*/
GNUNET_SERVER_receive_done (session->client,
GNUNET_SYSERR);
}
- else if (session->client != NULL)
- GNUNET_SERVER_client_drop (session->client);
+ if (session->client != NULL)
+ {
+ GNUNET_SERVER_client_drop (session->client);
+ session->client = NULL;
+ }
GNUNET_STATISTICS_update (session->plugin->env->stats,
gettext_noop ("# TCP sessions active"),
-1,
GNUNET_NO);
GNUNET_free_non_null (session->connect_addr);
-
session->plugin->env->session_end (session->plugin->env->cls,
&session->target,
session);
-
+ GNUNET_assert (NULL == session->transmit_handle);
GNUNET_free (session);
}
target,
NULL,
GNUNET_YES);
+ GNUNET_assert (session != NULL);
/* create new message entry */
pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
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"),
msgbuf_size,
}
session->last_activity = GNUNET_TIME_absolute_get ();
session->expecting_welcome = GNUNET_NO;
+ GNUNET_SERVER_client_set_timeout(client, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
&try_connection_reversal,
plugin);
while (ret > 0)
- GNUNET_free (addrs[--ret]);
+ {
+ ret--;
+ GNUNET_assert (addrs[ret] != NULL);
+ GNUNET_free (addrs[ret]);
+ }
GNUNET_free_non_null (addrs);
GNUNET_free_non_null (addrlens);
}