aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_udp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-10-23 14:38:21 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-10-23 14:38:21 +0000
commit58a402ee6c05a0a6f97a3026ab0c41f319bc1421 (patch)
treee4e096097496268b1661a4c36a632d47a09d70ee /src/transport/plugin_transport_udp.c
parent2497301006742d9b9dcaf8dc68fb4653e22711cc (diff)
downloadgnunet-58a402ee6c05a0a6f97a3026ab0c41f319bc1421.tar.gz
gnunet-58a402ee6c05a0a6f97a3026ab0c41f319bc1421.zip
- removal for fragmented messages
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r--src/transport/plugin_transport_udp.c139
1 files changed, 79 insertions, 60 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 630af4bfa..f67bbd915 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1003,6 +1003,66 @@ dequeue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
1003 plugin->ipv6_queue_tail, udpw); 1003 plugin->ipv6_queue_tail, udpw);
1004} 1004}
1005 1005
1006static void
1007fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1008{
1009 struct UDP_MessageWrapper *udpw;
1010 struct UDP_MessageWrapper *tmp;
1011 struct UDP_MessageWrapper dummy;
1012 struct Session *s = fc->session;
1013 LOG (GNUNET_ERROR_TYPE_DEBUG, "%p : Fragmented message removed with result %s\n", fc, (result == GNUNET_SYSERR) ? "FAIL" : "SUCCESS");
1014
1015 /* Call continuation for fragmented message */
1016 dummy.msg_type = MSG_FRAGMENTED_COMPLETE;
1017 dummy.msg_buf = NULL;
1018 dummy.msg_size = s->frag_ctx->on_wire_size;
1019 dummy.payload_size = s->frag_ctx->payload_size;
1020 dummy.frag_ctx = s->frag_ctx;
1021 dummy.session = s;
1022
1023 call_continuation (&dummy, result);
1024
1025 /* Remove left-over fragments from queue */
1026 /* Remove leftover fragments from queue */
1027 if (s->addrlen == sizeof (struct sockaddr_in6))
1028 {
1029 udpw = plugin->ipv6_queue_head;
1030 while (NULL != udpw)
1031 {
1032 tmp = udpw->next;
1033 if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
1034 {
1035 dequeue (plugin, udpw);
1036 call_continuation (udpw, GNUNET_SYSERR);
1037 GNUNET_free (udpw);
1038 }
1039 udpw = tmp;
1040 }
1041 }
1042 if (s->addrlen == sizeof (struct sockaddr_in))
1043 {
1044 udpw = plugin->ipv4_queue_head;
1045 while (udpw!= NULL)
1046 {
1047 tmp = udpw->next;
1048 if ((NULL != udpw->frag_ctx) && (udpw->frag_ctx == s->frag_ctx))
1049 {
1050 dequeue (plugin, udpw);
1051 call_continuation (udpw, GNUNET_SYSERR);
1052 GNUNET_free (udpw);
1053 }
1054 udpw = tmp;
1055 }
1056 }
1057
1058 /* Destroy fragmentation context */
1059 GNUNET_FRAGMENT_context_destroy (fc->frag,
1060 &s->last_expected_msg_delay,
1061 &s->last_expected_ack_delay);
1062 s->frag_ctx = NULL;
1063 GNUNET_free (fc);
1064}
1065
1006/** 1066/**
1007 * Functions with this signature are called whenever we need 1067 * Functions with this signature are called whenever we need
1008 * to close a session due to a disconnect or failure to 1068 * to close a session due to a disconnect or failure to
@@ -1023,6 +1083,13 @@ disconnect_session (struct Session *s)
1023 GNUNET_i2s (&s->target), 1083 GNUNET_i2s (&s->target),
1024 GNUNET_a2s (s->sock_addr, s->addrlen)); 1084 GNUNET_a2s (s->sock_addr, s->addrlen));
1025 stop_session_timeout (s); 1085 stop_session_timeout (s);
1086
1087 if (NULL != s->frag_ctx)
1088 {
1089 /* Remove fragmented message due to disconnect */
1090 fragmented_message_done (s->frag_ctx, GNUNET_SYSERR);
1091 }
1092
1026 next = plugin->ipv4_queue_head; 1093 next = plugin->ipv4_queue_head;
1027 while (NULL != (udpw = next)) 1094 while (NULL != (udpw = next))
1028 { 1095 {
@@ -1970,49 +2037,9 @@ read_process_ack (struct Plugin *plugin,
1970 "Message full ACK'ed\n", 2037 "Message full ACK'ed\n",
1971 (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), 2038 (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender),
1972 GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); 2039 GNUNET_a2s ((const struct sockaddr *) addr, fromlen));
1973 GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag,
1974 &s->last_expected_msg_delay,
1975 &s->last_expected_ack_delay);
1976 2040
1977 if (s->addrlen == sizeof (struct sockaddr_in6)) 2041 /* Remove fragmented message after successful sending */
1978 { 2042 fragmented_message_done (s->frag_ctx, GNUNET_OK);
1979 udpw = plugin->ipv6_queue_head;
1980 while (NULL != udpw)
1981 {
1982 tmp = udpw->next;
1983 if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == s->frag_ctx))
1984 {
1985 dequeue (plugin, udpw);
1986 GNUNET_free (udpw);
1987 }
1988 udpw = tmp;
1989 }
1990 }
1991 if (s->addrlen == sizeof (struct sockaddr_in))
1992 {
1993 udpw = plugin->ipv4_queue_head;
1994 while (udpw!= NULL)
1995 {
1996 tmp = udpw->next;
1997 if ((NULL != udpw->frag_ctx) && (udpw->frag_ctx == s->frag_ctx))
1998 {
1999 dequeue (plugin, udpw);
2000 GNUNET_free (udpw);
2001 }
2002 udpw = tmp;
2003 }
2004 }
2005 dummy.msg_type = MSG_FRAGMENTED_COMPLETE;
2006 dummy.msg_buf = NULL;
2007 dummy.msg_size = s->frag_ctx->on_wire_size;
2008 dummy.payload_size = s->frag_ctx->payload_size;
2009 dummy.frag_ctx = s->frag_ctx;
2010 dummy.session = s;
2011
2012 call_continuation (&dummy, GNUNET_OK);
2013
2014 GNUNET_free (s->frag_ctx);
2015 s->frag_ctx = NULL;
2016} 2043}
2017 2044
2018 2045
@@ -2182,6 +2209,9 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2182 LOG (GNUNET_ERROR_TYPE_DEBUG, 2209 LOG (GNUNET_ERROR_TYPE_DEBUG,
2183 "Message for peer `%s' with size %u timed out\n", 2210 "Message for peer `%s' with size %u timed out\n",
2184 GNUNET_i2s(&udpw->session->target), udpw->payload_size); 2211 GNUNET_i2s(&udpw->session->target), udpw->payload_size);
2212 /* Remove message */
2213 dequeue (plugin, udpw);
2214 GNUNET_free (udpw);
2185 break; 2215 break;
2186 case MSG_FRAGMENTED: 2216 case MSG_FRAGMENTED:
2187 /* Fragmented message */ 2217 /* Fragmented message */
@@ -2189,38 +2219,27 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2189 LOG (GNUNET_ERROR_TYPE_DEBUG, 2219 LOG (GNUNET_ERROR_TYPE_DEBUG,
2190 "Fragment for message for peer `%s' with size %u timed out\n", 2220 "Fragment for message for peer `%s' with size %u timed out\n",
2191 GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->payload_size); 2221 GNUNET_i2s(&udpw->session->target), udpw->frag_ctx->payload_size);
2192 GNUNET_FRAGMENT_context_destroy (udpw->frag_ctx->frag,
2193 &udpw->session->last_expected_msg_delay,
2194 &udpw->session->last_expected_ack_delay);
2195 GNUNET_free (udpw->frag_ctx);
2196 udpw->session->frag_ctx = NULL;
2197 2222
2223 /* Remove fragmented message due to timeout */
2224 fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR);
2198 break; 2225 break;
2199 case MSG_ACK: 2226 case MSG_ACK:
2200 LOG (GNUNET_ERROR_TYPE_DEBUG, 2227 LOG (GNUNET_ERROR_TYPE_DEBUG,
2201 "ACK Message for peer `%s' with size %u timed out\n", 2228 "ACK Message for peer `%s' with size %u timed out\n",
2202 GNUNET_i2s(&udpw->session->target), udpw->payload_size); 2229 GNUNET_i2s(&udpw->session->target), udpw->payload_size);
2230 dequeue (plugin, udpw);
2231 GNUNET_free (udpw);
2203 break; 2232 break;
2204 default: 2233 default:
2205 break; 2234 break;
2206 } 2235 }
2207
2208 GNUNET_STATISTICS_update (plugin->env->stats,
2209 "# messages dismissed due to timeout",
2210 1, GNUNET_NO);
2211 /* Remove message */
2212 if (sock == plugin->sockv4) 2236 if (sock == plugin->sockv4)
2213 {
2214 dequeue (plugin, udpw);
2215 GNUNET_free (udpw);
2216 udpw = plugin->ipv4_queue_head; 2237 udpw = plugin->ipv4_queue_head;
2217 }
2218 if (sock == plugin->sockv6) 2238 if (sock == plugin->sockv6)
2219 {
2220 dequeue (plugin, udpw);
2221 GNUNET_free (udpw);
2222 udpw = plugin->ipv6_queue_head; 2239 udpw = plugin->ipv6_queue_head;
2223 } 2240 GNUNET_STATISTICS_update (plugin->env->stats,
2241 "# messages dismissed due to timeout",
2242 1, GNUNET_NO);
2224 } 2243 }
2225 else 2244 else
2226 { 2245 {