diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-23 18:05:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-23 18:05:57 +0000 |
commit | 3e82863a722f3eabcbef960bcceb924049b35f81 (patch) | |
tree | dd9a449d8c6bec7d646c73c7484d0ad5a57570cb /src | |
parent | 252aa2534e470ace72364a65f13bed5bf07cc908 (diff) | |
download | gnunet-3e82863a722f3eabcbef960bcceb924049b35f81.tar.gz gnunet-3e82863a722f3eabcbef960bcceb924049b35f81.zip |
-simplify logic, just use clearly working direct method to extract session from server's client handle
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 58 |
1 files changed, 5 insertions, 53 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 01c3a0b1a..1175e442c 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -235,11 +235,6 @@ struct Session | |||
235 | struct GNUNET_PeerIdentity target; | 235 | struct GNUNET_PeerIdentity target; |
236 | 236 | ||
237 | /** | 237 | /** |
238 | * API requirement. | ||
239 | */ | ||
240 | struct SessionHeader header; | ||
241 | |||
242 | /** | ||
243 | * Pointer to the global plugin struct. | 238 | * Pointer to the global plugin struct. |
244 | */ | 239 | */ |
245 | struct Plugin *plugin; | 240 | struct Plugin *plugin; |
@@ -497,9 +492,10 @@ plugin_tcp_access_check (void *cls, | |||
497 | socklen_t addrlen) | 492 | socklen_t addrlen) |
498 | { | 493 | { |
499 | struct Plugin *plugin = cls; | 494 | struct Plugin *plugin = cls; |
500 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 495 | |
501 | "Accepting new incoming TCP connection from `%s'\n", | 496 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
502 | GNUNET_a2s (addr, addrlen)); | 497 | "Accepting new incoming TCP connection from `%s'\n", |
498 | GNUNET_a2s (addr, addrlen)); | ||
503 | if (plugin->cur_connections >= plugin->max_connections) | 499 | if (plugin->cur_connections >= plugin->max_connections) |
504 | return GNUNET_NO; | 500 | return GNUNET_NO; |
505 | plugin->cur_connections++; | 501 | plugin->cur_connections++; |
@@ -743,40 +739,6 @@ tcp_string_to_address (void *cls, | |||
743 | 739 | ||
744 | 740 | ||
745 | /** | 741 | /** |
746 | * Closure for #session_lookup_by_client_it(). | ||
747 | */ | ||
748 | struct SessionClientCtx | ||
749 | { | ||
750 | /** | ||
751 | * Client we are looking for. | ||
752 | */ | ||
753 | const struct GNUNET_SERVER_Client *client; | ||
754 | |||
755 | /** | ||
756 | * Session that was found. | ||
757 | */ | ||
758 | struct Session *ret; | ||
759 | }; | ||
760 | |||
761 | |||
762 | static int | ||
763 | session_lookup_by_client_it (void *cls, | ||
764 | const struct GNUNET_PeerIdentity *key, | ||
765 | void *value) | ||
766 | { | ||
767 | struct SessionClientCtx *sc_ctx = cls; | ||
768 | struct Session *s = value; | ||
769 | |||
770 | if (s->client == sc_ctx->client) | ||
771 | { | ||
772 | sc_ctx->ret = s; | ||
773 | return GNUNET_NO; | ||
774 | } | ||
775 | return GNUNET_YES; | ||
776 | } | ||
777 | |||
778 | |||
779 | /** | ||
780 | * Find the session handle for the given client. | 742 | * Find the session handle for the given client. |
781 | * Currently uses both the hashmap and the client | 743 | * Currently uses both the hashmap and the client |
782 | * context, as the client context is new and the | 744 | * context, as the client context is new and the |
@@ -790,17 +752,7 @@ static struct Session * | |||
790 | lookup_session_by_client (struct Plugin *plugin, | 752 | lookup_session_by_client (struct Plugin *plugin, |
791 | struct GNUNET_SERVER_Client *client) | 753 | struct GNUNET_SERVER_Client *client) |
792 | { | 754 | { |
793 | struct Session *ret; | 755 | return GNUNET_SERVER_client_get_user_context (client, struct Session); |
794 | struct SessionClientCtx sc_ctx; | ||
795 | |||
796 | ret = GNUNET_SERVER_client_get_user_context (client, struct Session); | ||
797 | sc_ctx.client = client; | ||
798 | sc_ctx.ret = NULL; | ||
799 | GNUNET_CONTAINER_multipeermap_iterate (plugin->sessionmap, | ||
800 | &session_lookup_by_client_it, &sc_ctx); | ||
801 | /* check both methods yield the same result */ | ||
802 | GNUNET_break(ret == sc_ctx.ret); | ||
803 | return sc_ctx.ret; | ||
804 | } | 756 | } |
805 | 757 | ||
806 | 758 | ||