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:45:55 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-02 14:45:55 +0000
commita4d2d006ed644cd965d7d80f8e4c4ad4988fc972 (patch)
tree1821afc8098bddedfcfbf1fac2e7a518196fe39a /src/transport/plugin_transport_tcp.c
parent82c4c89493dcbfc6ee7fd1232a9088d02e2cd0a2 (diff)
downloadgnunet-a4d2d006ed644cd965d7d80f8e4c4ad4988fc972.tar.gz
gnunet-a4d2d006ed644cd965d7d80f8e4c4ad4988fc972.zip
- fix for mantis 2189
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r--src/transport/plugin_transport_tcp.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index bc33a9a15..ff4b29451 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -901,13 +901,7 @@ tcp_plugin_send (void *cls,
901 901
902 GNUNET_assert (plugin != NULL); 902 GNUNET_assert (plugin != NULL);
903 GNUNET_assert (session != NULL); 903 GNUNET_assert (session != NULL);
904 GNUNET_assert (session->client != NULL);
905 904
906 GNUNET_SERVER_client_set_timeout (session->client,
907 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
908 GNUNET_STATISTICS_update (plugin->env->stats,
909 gettext_noop ("# bytes currently in TCP buffers"),
910 msgbuf_size, GNUNET_NO);
911 /* create new message entry */ 905 /* create new message entry */
912 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size); 906 pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size);
913 pm->msg = (const char *) &pm[1]; 907 pm->msg = (const char *) &pm[1];
@@ -917,16 +911,51 @@ tcp_plugin_send (void *cls,
917 pm->transmit_cont = cont; 911 pm->transmit_cont = cont;
918 pm->transmit_cont_cls = cont_cls; 912 pm->transmit_cont_cls = cont_cls;
919 913
920 /* append pm to pending_messages list */
921 GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
922 session->pending_messages_tail, pm);
923 914
924 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", 915 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
925 "Asked to transmit %u bytes to `%s', added message to list.\n", 916 "Asked to transmit %u bytes to `%s', added message to list.\n",
926 msgbuf_size, GNUNET_i2s (&session->target)); 917 msgbuf_size, GNUNET_i2s (&session->target));
927 918
928 process_pending_messages (session); 919 if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value(plugin->sessionmap, &session->target.hashPubKey, session))
929 return msgbuf_size; 920 {
921 GNUNET_assert (session->client != NULL);
922
923 GNUNET_SERVER_client_set_timeout (session->client,
924 GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
925 GNUNET_STATISTICS_update (plugin->env->stats,
926 gettext_noop ("# bytes currently in TCP buffers"),
927 msgbuf_size, GNUNET_NO);
928
929 /* append pm to pending_messages list */
930 GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
931 session->pending_messages_tail, pm);
932
933 process_pending_messages (session);
934 return msgbuf_size;
935 }
936 else if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value(plugin->nat_wait_conns, &session->target.hashPubKey, session))
937 {
938 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
939 "This NAT WAIT session for peer `%s' is not yet ready!\n",
940 GNUNET_i2s (&session->target));
941
942 GNUNET_STATISTICS_update (plugin->env->stats,
943 gettext_noop ("# bytes currently in TCP buffers"),
944 msgbuf_size, GNUNET_NO);
945
946 /* append pm to pending_messages list */
947 GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
948 session->pending_messages_tail, pm);
949 return msgbuf_size;
950 }
951 else
952 {
953 if (cont != NULL)
954 cont (cont_cls, &session->target, GNUNET_SYSERR);
955 GNUNET_break (0);
956 GNUNET_free (pm);
957 return GNUNET_SYSERR; /* session does not exist here */
958 }
930} 959}
931 960
932struct SessionItCtx 961struct SessionItCtx
@@ -1133,7 +1162,6 @@ tcp_plugin_get_session (void *cls,
1133 return session; 1162 return session;
1134 else 1163 else
1135 { 1164 {
1136 /* This is necessary for disconnect_session() to work */
1137 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp", 1165 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",
1138 "Running NAT client for `%4s' at `%s' failed\n", 1166 "Running NAT client for `%4s' at `%s' failed\n",
1139 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs)); 1167 GNUNET_i2s (&session->target), GNUNET_a2s (sb, sbs));