aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_tcp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-02 14:04:05 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-02 14:04:05 +0000
commit82894f45a92d4df70b8e038109a318f2489c4cfe (patch)
treeda96bb12d94b05abe81de69d2489bf6886c67b98 /src/transport/plugin_transport_tcp.c
parentfb9b068cf1b3783f7346d234fbbe84a3b6051524 (diff)
downloadgnunet-82894f45a92d4df70b8e038109a318f2489c4cfe.tar.gz
gnunet-82894f45a92d4df70b8e038109a318f2489c4cfe.zip
- LRN's patch: return value of nat client
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r--src/transport/plugin_transport_tcp.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 2b2d7289e..bc33a9a15 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1124,13 +1124,49 @@ tcp_plugin_get_session (void *cls,
1124 GNUNET_assert (GNUNET_CONTAINER_multihashmap_put 1124 GNUNET_assert (GNUNET_CONTAINER_multihashmap_put
1125 (plugin->nat_wait_conns, &address->peer.hashPubKey, session, 1125 (plugin->nat_wait_conns, &address->peer.hashPubKey, session,
1126 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == GNUNET_OK); 1126 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) == GNUNET_OK);
1127#if DEBUG_TCP_NAT 1127
1128 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", 1128 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1129 "Created NAT WAIT connection to `%4s' at `%s'\n", 1129 "Created NAT WAIT connection to `%4s' at `%s'\n",
1130 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs)); 1130 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));
1131#endif 1131
1132 GNUNET_NAT_run_client (plugin->nat, &a4); 1132 if (GNUNET_OK == GNUNET_NAT_run_client (plugin->nat, &a4))
1133 return session; 1133 return session;
1134 else
1135 {
1136 /* This is necessary for disconnect_session() to work */
1137 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1138 "Running NAT client for `%4s' at `%s' failed\n",
1139 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));
1140
1141 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (
1142 plugin->nat_wait_conns,
1143 &address->peer.hashPubKey,
1144 session));
1145
1146 /* cleaning up welcome msg and update statistics */
1147 struct PendingMessage *pm;
1148 while (NULL != (pm = session->pending_messages_head))
1149 {
1150 GNUNET_STATISTICS_update (session->plugin->env->stats,
1151 gettext_noop ("# bytes currently in TCP buffers"),
1152 -(int64_t) pm->message_size, GNUNET_NO);
1153 GNUNET_STATISTICS_update (session->plugin->env->stats,
1154 gettext_noop
1155 ("# bytes discarded by TCP (disconnect)"),
1156 pm->message_size, GNUNET_NO);
1157 GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
1158 session->pending_messages_tail, pm);
1159 GNUNET_free (pm);
1160 }
1161
1162 GNUNET_STATISTICS_update (session->plugin->env->stats,
1163 gettext_noop ("# TCP sessions active"), -1,
1164 GNUNET_NO);
1165 GNUNET_free_non_null (session->addr);
1166 GNUNET_free (session);
1167 session = NULL;
1168 return NULL;
1169 }
1134 } 1170 }
1135 1171
1136 /* create new outbound session */ 1172 /* create new outbound session */