diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-06-20 16:26:18 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-06-20 16:26:18 +0000 |
commit | c6d721c32f12f97a189d6533862839fb1a8d2e97 (patch) | |
tree | 6758a337bc0ab548d8e6b40a6cb6fd471f1a33b4 /src/transport/plugin_transport_tcp.c | |
parent | e88743d18bdef4022a53813f5e172ec12a32741b (diff) | |
download | gnunet-c6d721c32f12f97a189d6533862839fb1a8d2e97.tar.gz gnunet-c6d721c32f12f97a189d6533862839fb1a8d2e97.zip |
- workaround for mantis 0002445
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 450209aff..a42621569 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -1019,6 +1019,31 @@ disconnect_session (struct Session *session) | |||
1019 | GNUNET_free (session); | 1019 | GNUNET_free (session); |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | /* FIXME WORKAROUND FOR MANTIS 0002445 */ | ||
1023 | struct result | ||
1024 | { | ||
1025 | struct Session *s; | ||
1026 | int res; | ||
1027 | }; | ||
1028 | |||
1029 | int session_it (void *cls, | ||
1030 | const struct GNUNET_HashCode * key, | ||
1031 | void *value) | ||
1032 | { | ||
1033 | struct result *res = cls; | ||
1034 | |||
1035 | if (res->s == value) | ||
1036 | { | ||
1037 | res->res = GNUNET_OK; | ||
1038 | return GNUNET_NO; | ||
1039 | } | ||
1040 | else | ||
1041 | { | ||
1042 | return GNUNET_YES; | ||
1043 | } | ||
1044 | } | ||
1045 | |||
1046 | /* FIXME END WORKAROUND FOR MANTIS 0002445 */ | ||
1022 | 1047 | ||
1023 | /** | 1048 | /** |
1024 | * Function that can be used by the transport service to transmit | 1049 | * Function that can be used by the transport service to transmit |
@@ -1061,6 +1086,27 @@ tcp_plugin_send (void *cls, | |||
1061 | GNUNET_assert (NULL != plugin); | 1086 | GNUNET_assert (NULL != plugin); |
1062 | GNUNET_assert (NULL != session); | 1087 | GNUNET_assert (NULL != session); |
1063 | 1088 | ||
1089 | /* FIXME WORKAROUND FOR MANTIS 0002445 */ | ||
1090 | struct result res1; | ||
1091 | struct result res2; | ||
1092 | |||
1093 | res1.s = session; | ||
1094 | res1.res = GNUNET_SYSERR; | ||
1095 | GNUNET_CONTAINER_multihashmap_iterate (plugin->sessionmap, &session_it, &res1); | ||
1096 | |||
1097 | res2.s = session; | ||
1098 | res2.res = GNUNET_SYSERR; | ||
1099 | GNUNET_CONTAINER_multihashmap_iterate (plugin->sessionmap, &session_it, &res2); | ||
1100 | |||
1101 | if ((res1.res == GNUNET_SYSERR) && (res2.res == GNUNET_SYSERR)) | ||
1102 | { | ||
1103 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1104 | "WORKAROUND MANTIS BUG 2445: This Trying to send to invalid session %p\n", session); | ||
1105 | GNUNET_break (0); | ||
1106 | return GNUNET_SYSERR; | ||
1107 | } | ||
1108 | /* FIXME END WORKAROUND FOR MANTIS 0002445 */ | ||
1109 | |||
1064 | /* create new message entry */ | 1110 | /* create new message entry */ |
1065 | pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size); | 1111 | pm = GNUNET_malloc (sizeof (struct PendingMessage) + msgbuf_size); |
1066 | pm->msg = (const char *) &pm[1]; | 1112 | pm->msg = (const char *) &pm[1]; |
@@ -1074,12 +1120,10 @@ tcp_plugin_send (void *cls, | |||
1074 | "Asked to transmit %u bytes to `%s', added message to list.\n", | 1120 | "Asked to transmit %u bytes to `%s', added message to list.\n", |
1075 | msgbuf_size, GNUNET_i2s (&session->target)); | 1121 | msgbuf_size, GNUNET_i2s (&session->target)); |
1076 | 1122 | ||
1077 | reschedule_session_timeout (session); | ||
1078 | |||
1079 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value(plugin->sessionmap, &session->target.hashPubKey, session)) | 1123 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value(plugin->sessionmap, &session->target.hashPubKey, session)) |
1080 | { | 1124 | { |
1081 | GNUNET_assert (session->client != NULL); | 1125 | GNUNET_assert (session->client != NULL); |
1082 | 1126 | reschedule_session_timeout (session); | |
1083 | GNUNET_SERVER_client_set_timeout (session->client, | 1127 | GNUNET_SERVER_client_set_timeout (session->client, |
1084 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 1128 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); |
1085 | GNUNET_STATISTICS_update (plugin->env->stats, | 1129 | GNUNET_STATISTICS_update (plugin->env->stats, |
@@ -1098,7 +1142,7 @@ tcp_plugin_send (void *cls, | |||
1098 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1142 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1099 | "This NAT WAIT session for peer `%s' is not yet ready!\n", | 1143 | "This NAT WAIT session for peer `%s' is not yet ready!\n", |
1100 | GNUNET_i2s (&session->target)); | 1144 | GNUNET_i2s (&session->target)); |
1101 | 1145 | reschedule_session_timeout (session); | |
1102 | GNUNET_STATISTICS_update (plugin->env->stats, | 1146 | GNUNET_STATISTICS_update (plugin->env->stats, |
1103 | gettext_noop ("# bytes currently in TCP buffers"), | 1147 | gettext_noop ("# bytes currently in TCP buffers"), |
1104 | msgbuf_size, GNUNET_NO); | 1148 | msgbuf_size, GNUNET_NO); |
@@ -1110,6 +1154,8 @@ tcp_plugin_send (void *cls, | |||
1110 | } | 1154 | } |
1111 | else | 1155 | else |
1112 | { | 1156 | { |
1157 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1158 | "Invalid session %p\n", session); | ||
1113 | if (NULL != cont) | 1159 | if (NULL != cont) |
1114 | cont (cont_cls, &session->target, GNUNET_SYSERR); | 1160 | cont (cont_cls, &session->target, GNUNET_SYSERR); |
1115 | GNUNET_break (0); | 1161 | GNUNET_break (0); |