From: Matthias Wachs Date: Tue, 29 May 2012 09:05:12 +0000 (+0000) Subject: - refactorind reverting last fix X-Git-Tag: initial-import-from-subversion-38251~13369 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cec8e7eee09c84d32e7e8c6ae18d03a43eaa3e13;p=oweals%2Fgnunet.git - refactorind reverting last fix --- diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 2bc82d8f0..d55cdb76b 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -601,6 +601,8 @@ delete_session (struct Session *s) s->msg_tk = NULL; } GNUNET_free (s->addr); + GNUNET_free_non_null (s->server_recv); + GNUNET_free_non_null (s->server_send); GNUNET_free (s); } diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h index 8ec47fe4c..c3c9367ad 100644 --- a/src/transport/plugin_transport_http.h +++ b/src/transport/plugin_transport_http.h @@ -305,6 +305,24 @@ struct IPv6HttpAddress }; GNUNET_NETWORK_STRUCT_END + +struct ServerConnection +{ + /* _RECV or _SEND */ + int direction; + + /* Should this connection get disconnected? GNUNET_YES/NO */ + int disconnect; + + /* The session this server connection belongs to */ + struct Session *session; + + /* The MHD connection */ + struct MHD_Connection *mhd_conn; +}; + + + /** * Session handle for connections. */ @@ -417,12 +435,12 @@ struct Session /** * Client send handle */ - void *server_recv; + struct ServerConnection *server_recv; /** * Client send handle */ - void *server_send; + struct ServerConnection *server_send; }; /** diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index d8383b0a9..58c8fd215 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -32,18 +32,6 @@ static struct Plugin * p; -struct ServerConnection -{ - /* _RECV or _SEND */ - int direction; - - /* should this connection get disconnected? GNUNET_YES/NO */ - int disconnect; - - struct Session *session; - struct MHD_Connection *mhd_conn; -}; - /** * Function that queries MHD's select sets and * starts the task waiting for them. @@ -540,14 +528,9 @@ create: s = create_session (plugin, &target, a, a_len); GNUNET_assert (NULL != s); s->ats_address_network_type = ats.value; - s->inbound = GNUNET_YES; s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS; s->tag = tag; - if (0 == strcmp (MHD_HTTP_METHOD_PUT, method)) - s->server_recv = s; - if (0 == strcmp (MHD_HTTP_METHOD_GET, method)) - s->server_send = s; GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head, plugin->server_semi_tail, s); goto found; @@ -853,24 +836,15 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, int server_disconnect (struct Session *s) { - struct Plugin *plugin = s->plugin; - struct Session *t = plugin->head; - - while (t != NULL) + if (s->server_send != NULL) { - if (t->inbound == GNUNET_YES) - { - if (t->server_send != NULL) - { - ((struct ServerConnection *) t->server_send)->disconnect = GNUNET_YES; - } - if (t->server_send != NULL) - { - ((struct ServerConnection *) t->server_send)->disconnect = GNUNET_YES; - } - } - t = t->next; + ((struct ServerConnection *) s->server_send)->disconnect = GNUNET_YES; + } + if (s->server_recv != NULL) + { + ((struct ServerConnection *) s->server_recv)->disconnect = GNUNET_YES; } + return GNUNET_OK; }