aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-15 16:58:41 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-15 16:58:41 +0000
commit560518030f95c0cef46844df4cfddcaf8b127a12 (patch)
tree60cb0d6c7e5a11d7b79915e2507e8a4e1661b8fa
parent06415e68bc0a5df3c4c509151a474e0a901c7c64 (diff)
downloadgnunet-560518030f95c0cef46844df4cfddcaf8b127a12.tar.gz
gnunet-560518030f95c0cef46844df4cfddcaf8b127a12.zip
-cleanup
-rw-r--r--src/transport/plugin_transport_tcp.c29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 1a4ab765a..703be2fb2 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -651,7 +651,9 @@ struct SessionClientCtx
651 struct Session *ret; 651 struct Session *ret;
652}; 652};
653 653
654int session_lookup_by_client_it (void *cls, 654
655static int
656session_lookup_by_client_it (void *cls,
655 const GNUNET_HashCode * key, 657 const GNUNET_HashCode * key,
656 void *value) 658 void *value)
657{ 659{
@@ -666,6 +668,7 @@ int session_lookup_by_client_it (void *cls,
666 return GNUNET_YES; 668 return GNUNET_YES;
667} 669}
668 670
671
669/** 672/**
670 * Find the session handle for the given client. 673 * Find the session handle for the given client.
671 * 674 *
@@ -678,11 +681,10 @@ lookup_session_by_client (struct Plugin *plugin,
678 const struct GNUNET_SERVER_Client *client) 681 const struct GNUNET_SERVER_Client *client)
679{ 682{
680 struct SessionClientCtx sc_ctx; 683 struct SessionClientCtx sc_ctx;
684
681 sc_ctx.client = client; 685 sc_ctx.client = client;
682 sc_ctx.ret = NULL; 686 sc_ctx.ret = NULL;
683
684 GNUNET_CONTAINER_multihashmap_iterate (plugin->sessionmap, &session_lookup_by_client_it, &sc_ctx); 687 GNUNET_CONTAINER_multihashmap_iterate (plugin->sessionmap, &session_lookup_by_client_it, &sc_ctx);
685
686 return sc_ctx.ret; 688 return sc_ctx.ret;
687} 689}
688 690
@@ -714,10 +716,6 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
714 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", 716 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
715 "Creating new session for peer `%4s'\n", 717 "Creating new session for peer `%4s'\n",
716 GNUNET_i2s (target)); 718 GNUNET_i2s (target));
717 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
718 "Creating new TCP session for peer `%s'\n",
719 GNUNET_i2s (target));
720
721 ret = GNUNET_malloc (sizeof (struct Session)); 719 ret = GNUNET_malloc (sizeof (struct Session));
722 ret->last_activity = GNUNET_TIME_absolute_get (); 720 ret->last_activity = GNUNET_TIME_absolute_get ();
723 ret->plugin = plugin; 721 ret->plugin = plugin;
@@ -1298,7 +1296,6 @@ tcp_plugin_get_session (void *cls,
1298 &nat_connect_timeout, 1296 &nat_connect_timeout,
1299 session); 1297 session);
1300 GNUNET_assert (session != NULL); 1298 GNUNET_assert (session != NULL);
1301
1302 GNUNET_assert (GNUNET_CONTAINER_multihashmap_put 1299 GNUNET_assert (GNUNET_CONTAINER_multihashmap_put
1303 (plugin->nat_wait_conns, &address->peer.hashPubKey, session, 1300 (plugin->nat_wait_conns, &address->peer.hashPubKey, session,
1304 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == GNUNET_OK); 1301 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == GNUNET_OK);
@@ -1395,20 +1392,11 @@ static void
1395tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) 1392tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
1396{ 1393{
1397 struct Plugin *plugin = cls; 1394 struct Plugin *plugin = cls;
1398 struct Session *nat_session = NULL;
1399 1395
1400 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", 1396 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1401 "Disconnecting peer `%4s'\n", GNUNET_i2s (target)); 1397 "Disconnecting peer `%4s'\n", GNUNET_i2s (target));
1402 1398 GNUNET_CONTAINER_multihashmap_get_multiple (plugin->sessionmap, &target->hashPubKey, &session_disconnect_it, plugin);
1403 GNUNET_CONTAINER_multihashmap_get_multiple (plugin->sessionmap, &target->hashPubKey, session_disconnect_it, plugin); 1399 GNUNET_CONTAINER_multihashmap_get_multiple (plugin->nat_wait_conns, &session_disconnect_it, plugin);
1404
1405 nat_session = GNUNET_CONTAINER_multihashmap_get(plugin->nat_wait_conns, &target->hashPubKey);
1406 if (nat_session != NULL)
1407 {
1408 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1409 "Cleaning up pending NAT session for peer `%4s'\n", GNUNET_i2s (target));
1410 disconnect_session (nat_session);
1411 }
1412} 1400}
1413 1401
1414 1402
@@ -1776,14 +1764,12 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client,
1776 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1764 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1777 return; 1765 return;
1778 } 1766 }
1779
1780 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", 1767 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp",
1781 "Received %s message from `%4s'\n", "WELCOME", 1768 "Received %s message from `%4s'\n", "WELCOME",
1782 GNUNET_i2s (&wm->clientIdentity)); 1769 GNUNET_i2s (&wm->clientIdentity));
1783 GNUNET_STATISTICS_update (plugin->env->stats, 1770 GNUNET_STATISTICS_update (plugin->env->stats,
1784 gettext_noop ("# TCP WELCOME messages received"), 1, 1771 gettext_noop ("# TCP WELCOME messages received"), 1,
1785 GNUNET_NO); 1772 GNUNET_NO);
1786
1787 session = lookup_session_by_client (plugin, client); 1773 session = lookup_session_by_client (plugin, client);
1788 if (session != NULL) 1774 if (session != NULL)
1789 { 1775 {
@@ -1801,7 +1787,6 @@ handle_tcp_welcome (void *cls, struct GNUNET_SERVER_Client *client,
1801 GNUNET_SERVER_client_keep (client); 1787 GNUNET_SERVER_client_keep (client);
1802 session = create_session (plugin, &wm->clientIdentity, client, GNUNET_NO); 1788 session = create_session (plugin, &wm->clientIdentity, client, GNUNET_NO);
1803 session->inbound = GNUNET_YES; 1789 session->inbound = GNUNET_YES;
1804
1805 if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 1790 if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
1806 { 1791 {
1807 if (alen == sizeof (struct sockaddr_in)) 1792 if (alen == sizeof (struct sockaddr_in))