};
+/* DEBUG CODE */
+static const char *
+tcp_address_to_string (void *cls, const void *addr, size_t addrlen);
+
+static unsigned int sessions;
+
+static void inc_sessions (struct Plugin *plugin, struct Session *session, int line)
+{
+ sessions ++;
+ unsigned int size = GNUNET_CONTAINER_multihashmap_size(plugin->sessionmap);
+ if (sessions != size)
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Inconsistent sessions %u <-> session map size: %u\n",
+ sessions, size);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "%4i Session increased to %u (session map size: %u): `%s' `%s'\n",
+ line,
+ sessions,
+ size,
+ GNUNET_i2s (&session->target),
+ tcp_address_to_string (NULL, session->addr, session->addrlen));
+}
+
+static void dec_sessions (struct Plugin *plugin, struct Session *session, int line)
+{
+ GNUNET_assert (sessions > 0);
+ unsigned int size = GNUNET_CONTAINER_multihashmap_size(plugin->sessionmap);
+ sessions --;
+ if (sessions != size)
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "Inconsistent sessions %u <-> session map size: %u\n",
+ sessions, size);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", "%4i Session decreased to %u (session map size: %u): `%s' `%s'\n",
+ line,
+ sessions,
+ size,
+ GNUNET_i2s (&session->target),
+ tcp_address_to_string (NULL, session->addr, session->addrlen));
+}
+/* DEBUG CODE */
+
/**
* Function to check if an inbound connection is acceptable.
GNUNET_CONTAINER_DLL_insert (ret->pending_messages_head,
ret->pending_messages_tail, pm);
if (is_nat != GNUNET_YES)
+ {
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP sessions active"), 1,
GNUNET_NO);
+ }
return ret;
}
GNUNET_i2s (&session->target),
tcp_address_to_string(NULL, session->addr, session->addrlen));
- GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(plugin->sessionmap, &session->target.hashPubKey, session) ||
- GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(plugin->nat_wait_conns, &session->target.hashPubKey, session));
+ if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(plugin->sessionmap, &session->target.hashPubKey, session))
+ {
+ GNUNET_STATISTICS_update (session->plugin->env->stats,
+ gettext_noop ("# TCP sessions active"), -1,
+ GNUNET_NO);
+ dec_sessions (plugin, session, __LINE__);
+ }
+ else GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(plugin->nat_wait_conns, &session->target.hashPubKey, session));
/* clean up state */
if (session->transmit_handle != 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->addr);
GNUNET_assert (NULL == session->transmit_handle);
GNUNET_free (session);
session->ats_address_network_type = ats.value;
GNUNET_CONTAINER_multihashmap_put(plugin->sessionmap, &address->peer.hashPubKey, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-
+ inc_sessions (plugin, session, __LINE__);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
"Creating new session for `%s' address `%s' session %p\n",
GNUNET_i2s (&address->peer),
GNUNET_free (vaddr);
GNUNET_CONTAINER_multihashmap_put(plugin->sessionmap, &session->target.hashPubKey, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-
+ inc_sessions (plugin, session, __LINE__);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP sessions active"), 1,
GNUNET_NO);
#endif
}
GNUNET_CONTAINER_multihashmap_put(plugin->sessionmap, &wm->clientIdentity.hashPubKey, session, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ inc_sessions (plugin, session, __LINE__);
}
if (session->expecting_welcome != GNUNET_YES)