diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index a5db667b7..3702d99be 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -42,6 +42,9 @@ | |||
42 | 42 | ||
43 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) | 43 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
44 | 44 | ||
45 | /** | ||
46 | * After how much inactivity should a UDP session time out? | ||
47 | */ | ||
45 | #define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 48 | #define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) |
46 | 49 | ||
47 | /** | 50 | /** |
@@ -57,7 +60,7 @@ | |||
57 | /** | 60 | /** |
58 | * We keep a defragmentation queue per sender address. How many | 61 | * We keep a defragmentation queue per sender address. How many |
59 | * sender addresses do we support at the same time? Memory consumption | 62 | * sender addresses do we support at the same time? Memory consumption |
60 | * is roughly a factor of 32k * UDP_MAX_MESSAGES_IN_DEFRAG times this | 63 | * is roughly a factor of 32k * #UDP_MAX_MESSAGES_IN_DEFRAG times this |
61 | * value. (So 128 corresponds to 12 MB and should suffice for | 64 | * value. (So 128 corresponds to 12 MB and should suffice for |
62 | * connecting to roughly 128 peers via UDP). | 65 | * connecting to roughly 128 peers via UDP). |
63 | */ | 66 | */ |
@@ -211,23 +214,6 @@ struct Session | |||
211 | 214 | ||
212 | 215 | ||
213 | /** | 216 | /** |
214 | * Closure for #process_inbound_tokenized_messages(). | ||
215 | */ | ||
216 | struct SourceInformation | ||
217 | { | ||
218 | /** | ||
219 | * Sender identity. | ||
220 | */ | ||
221 | struct GNUNET_PeerIdentity sender; | ||
222 | |||
223 | /** | ||
224 | * Associated session. | ||
225 | */ | ||
226 | struct Session *session; | ||
227 | |||
228 | }; | ||
229 | |||
230 | /** | ||
231 | * Closure for #find_receive_context(). | 217 | * Closure for #find_receive_context(). |
232 | */ | 218 | */ |
233 | struct FindReceiveContext | 219 | struct FindReceiveContext |
@@ -2242,7 +2228,7 @@ udp_nat_port_map_callback (void *cls, | |||
2242 | * to the service. | 2228 | * to the service. |
2243 | * | 2229 | * |
2244 | * @param cls the `struct Plugin *` | 2230 | * @param cls the `struct Plugin *` |
2245 | * @param client the `struct SourceInformation *` | 2231 | * @param client the `struct Session *` |
2246 | * @param hdr the actual message | 2232 | * @param hdr the actual message |
2247 | * @return #GNUNET_OK (always) | 2233 | * @return #GNUNET_OK (always) |
2248 | */ | 2234 | */ |
@@ -2252,19 +2238,18 @@ process_inbound_tokenized_messages (void *cls, | |||
2252 | const struct GNUNET_MessageHeader *hdr) | 2238 | const struct GNUNET_MessageHeader *hdr) |
2253 | { | 2239 | { |
2254 | struct Plugin *plugin = cls; | 2240 | struct Plugin *plugin = cls; |
2255 | struct SourceInformation *si = client; | 2241 | struct Session *session = client; |
2256 | struct GNUNET_TIME_Relative delay; | 2242 | struct GNUNET_TIME_Relative delay; |
2257 | 2243 | ||
2258 | GNUNET_assert (NULL != si->session); | 2244 | if (GNUNET_YES == session->in_destroy) |
2259 | if (GNUNET_YES == si->session->in_destroy) | ||
2260 | return GNUNET_OK; | 2245 | return GNUNET_OK; |
2261 | /* setup ATS */ | 2246 | /* setup ATS */ |
2262 | reschedule_session_timeout (si->session); | 2247 | reschedule_session_timeout (session); |
2263 | delay = plugin->env->receive (plugin->env->cls, | 2248 | delay = plugin->env->receive (plugin->env->cls, |
2264 | si->session->address, | 2249 | session->address, |
2265 | si->session, | 2250 | session, |
2266 | hdr); | 2251 | hdr); |
2267 | si->session->flow_delay_for_other_peer = delay; | 2252 | session->flow_delay_for_other_peer = delay; |
2268 | return GNUNET_OK; | 2253 | return GNUNET_OK; |
2269 | } | 2254 | } |
2270 | 2255 | ||
@@ -2285,7 +2270,6 @@ process_udp_message (struct Plugin *plugin, | |||
2285 | size_t udp_addr_len, | 2270 | size_t udp_addr_len, |
2286 | enum GNUNET_ATS_Network_Type network_type) | 2271 | enum GNUNET_ATS_Network_Type network_type) |
2287 | { | 2272 | { |
2288 | struct SourceInformation si; | ||
2289 | struct Session *s; | 2273 | struct Session *s; |
2290 | struct GNUNET_HELLO_Address *address; | 2274 | struct GNUNET_HELLO_Address *address; |
2291 | 2275 | ||
@@ -2327,11 +2311,9 @@ process_udp_message (struct Plugin *plugin, | |||
2327 | GNUNET_free (address); | 2311 | GNUNET_free (address); |
2328 | 2312 | ||
2329 | /* iterate over all embedded messages */ | 2313 | /* iterate over all embedded messages */ |
2330 | si.session = s; | ||
2331 | si.sender = msg->sender; | ||
2332 | s->rc++; | 2314 | s->rc++; |
2333 | GNUNET_SERVER_mst_receive (plugin->mst, | 2315 | GNUNET_SERVER_mst_receive (plugin->mst, |
2334 | &si, | 2316 | s, |
2335 | (const char *) &msg[1], | 2317 | (const char *) &msg[1], |
2336 | ntohs (msg->header.size) - sizeof(struct UDPMessage), | 2318 | ntohs (msg->header.size) - sizeof(struct UDPMessage), |
2337 | GNUNET_YES, | 2319 | GNUNET_YES, |