diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-10 10:07:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-10 10:07:55 +0000 |
commit | b2d0ae1548422121ba8d3a67356fd7409181bbd8 (patch) | |
tree | ccb85fe58bb19c84f99260d81589f5eb8c86e284 /src | |
parent | 1c66b3c347defc841efed00bfe682f6a4df431fe (diff) | |
download | gnunet-b2d0ae1548422121ba8d3a67356fd7409181bbd8.tar.gz gnunet-b2d0ae1548422121ba8d3a67356fd7409181bbd8.zip |
-fixing UDP fix
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 363af8a43..441f49bc7 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -119,6 +119,8 @@ struct Session | |||
119 | 119 | ||
120 | struct FragmentationContext * frag_ctx; | 120 | struct FragmentationContext * frag_ctx; |
121 | 121 | ||
122 | unsigned int rc; | ||
123 | |||
122 | int in_destroy; | 124 | int in_destroy; |
123 | }; | 125 | }; |
124 | 126 | ||
@@ -617,15 +619,11 @@ udp_plugin_check_address (void *cls, const void *addr, size_t addrlen) | |||
617 | /** | 619 | /** |
618 | * Task to free resources associated with a session. | 620 | * Task to free resources associated with a session. |
619 | * | 621 | * |
620 | * @param cls the 'struct Session' to free | 622 | * @param s session to free |
621 | * @param tc scheduler context (unused) | ||
622 | */ | 623 | */ |
623 | static void | 624 | static void |
624 | free_session (void *cls, | 625 | free_session (struct Session *s) |
625 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
626 | { | 626 | { |
627 | struct Session *s = cls; | ||
628 | |||
629 | if (s->frag_ctx != NULL) | 627 | if (s->frag_ctx != NULL) |
630 | { | 628 | { |
631 | GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag); | 629 | GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag); |
@@ -693,8 +691,10 @@ disconnect_and_free_it (void *cls, const GNUNET_HashCode * key, void *value) | |||
693 | "# UDP sessions active", | 691 | "# UDP sessions active", |
694 | GNUNET_CONTAINER_multihashmap_size(plugin->sessions), | 692 | GNUNET_CONTAINER_multihashmap_size(plugin->sessions), |
695 | GNUNET_NO); | 693 | GNUNET_NO); |
696 | GNUNET_SCHEDULER_add_now (&free_session, s); | 694 | if (s->rc > 0) |
697 | s->in_destroy = GNUNET_YES; | 695 | s->in_destroy = GNUNET_YES; |
696 | else | ||
697 | free_session (s); | ||
698 | return GNUNET_OK; | 698 | return GNUNET_OK; |
699 | } | 699 | } |
700 | 700 | ||
@@ -1265,7 +1265,7 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
1265 | socklen_t sender_addr_len) | 1265 | socklen_t sender_addr_len) |
1266 | { | 1266 | { |
1267 | struct SourceInformation si; | 1267 | struct SourceInformation si; |
1268 | struct Session * s = NULL; | 1268 | struct Session * s; |
1269 | struct IPv4UdpAddress u4; | 1269 | struct IPv4UdpAddress u4; |
1270 | struct IPv6UdpAddress u6; | 1270 | struct IPv6UdpAddress u6; |
1271 | const void *arg; | 1271 | const void *arg; |
@@ -1318,10 +1318,13 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
1318 | si.sender = msg->sender; | 1318 | si.sender = msg->sender; |
1319 | si.arg = arg; | 1319 | si.arg = arg; |
1320 | si.args = args; | 1320 | si.args = args; |
1321 | 1321 | s->rc++; | |
1322 | GNUNET_SERVER_mst_receive (plugin->mst, &si, (const char *) &msg[1], | 1322 | GNUNET_SERVER_mst_receive (plugin->mst, &si, (const char *) &msg[1], |
1323 | ntohs (msg->header.size) - | 1323 | ntohs (msg->header.size) - |
1324 | sizeof (struct UDPMessage), GNUNET_YES, GNUNET_NO); | 1324 | sizeof (struct UDPMessage), GNUNET_YES, GNUNET_NO); |
1325 | s->rc--; | ||
1326 | if ( (0 == s->rc) && (GNUNET_YES == s->in_destroy)) | ||
1327 | free_session (s); | ||
1325 | } | 1328 | } |
1326 | 1329 | ||
1327 | 1330 | ||