From: Matthias Wachs Date: Thu, 26 Apr 2012 11:37:50 +0000 (+0000) Subject: - fix for http X-Git-Tag: initial-import-from-subversion-38251~13768 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=435eded3cf216363f75e1904254c22c7c5fd987a;p=oweals%2Fgnunet.git - fix for http --- diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 076bef130..fb06bd7f5 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -532,6 +532,23 @@ lookup_session (struct Plugin *plugin, return NULL; } +int +exist_session (struct Plugin *plugin, struct Session *s) +{ + struct Session * head; + + GNUNET_assert (NULL != plugin); + GNUNET_assert (NULL != s); + + for (head = plugin->head; head != NULL; head = head->next) + { + if (head == s) + return GNUNET_YES; + } + return GNUNET_NO; +} + + void delete_session (struct Session *s) diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index b079c1732..eefc98b2e 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -26,6 +26,8 @@ #include "plugin_transport_http.h" +static struct Plugin * p; + #if VERBOSE_CURL /** * Function to log curl debug messages with GNUNET_log @@ -147,6 +149,12 @@ client_send (struct Session *s, struct HTTP_Message *msg) GNUNET_assert (s != NULL); GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg); + if (GNUNET_YES != exist_session(p, s)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + if (s->client_put_paused == GNUNET_YES) { #if VERBOSE_CLIENT @@ -210,6 +218,13 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_assert (CURLE_OK == curl_easy_getinfo (easy_h, CURLINFO_PRIVATE, &d)); s = (struct Session *) d; + + if (GNUNET_YES != exist_session(plugin, s)) + { + GNUNET_break (0); + return; + } + GNUNET_assert (s != NULL); if (msg->msg == CURLMSG_DONE) @@ -241,7 +256,11 @@ client_disconnect (struct Session *s) struct HTTP_Message *msg; struct HTTP_Message *t; - + if (GNUNET_YES != exist_session(plugin, s)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } if (s->client_put != NULL) { @@ -319,6 +338,12 @@ client_receive_mst_cb (void *cls, void *client, struct Session *s = cls; struct GNUNET_TIME_Relative delay; + if (GNUNET_YES != exist_session(p, s)) + { + GNUNET_break (0); + return; + } + delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen); s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); @@ -341,6 +366,12 @@ client_wake_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct Session *s = cls; + if (GNUNET_YES != exist_session(p, s)) + { + GNUNET_break (0); + return; + } + s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) @@ -371,6 +402,8 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) size_t len = size * nmemb; + + #if VERBOSE_CLIENT struct Plugin *plugin = s->plugin; @@ -429,6 +462,12 @@ client_send_cb (void *stream, size_t size, size_t nmemb, void *cls) size_t bytes_sent = 0; size_t len; + if (GNUNET_YES != exist_session(plugin, s)) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + struct HTTP_Message *msg = s->msg_head; if (msg == NULL) @@ -610,6 +649,7 @@ int client_start (struct Plugin *plugin) { int res = GNUNET_OK; + p = plugin; curl_global_init (CURL_GLOBAL_ALL); plugin->client_mh = curl_multi_init (); @@ -619,7 +659,7 @@ client_start (struct Plugin *plugin) GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, _ ("Could not initialize curl multi handle, failed to start %s plugin!\n"), - plugin->name); + plugin->name); res = GNUNET_SYSERR; } return res; @@ -628,6 +668,7 @@ client_start (struct Plugin *plugin) void client_stop (struct Plugin *plugin) { + p = NULL; if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (plugin->client_perform_task); diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 499fd06c8..22196b218 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -30,6 +30,8 @@ #define _RECEIVE 0 #define _SEND 1 +static struct Plugin * p; + struct ServerConnection { /* _RECV or _SEND */ @@ -279,6 +281,11 @@ server_receive_mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) { struct Session *s = cls; + + GNUNET_assert (NULL != p); + if (GNUNET_NO == exist_session(p, s)) + return; + struct Plugin *plugin = s->plugin; struct GNUNET_TIME_Relative delay; @@ -309,6 +316,9 @@ static ssize_t server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) { struct Session *s = cls; + GNUNET_assert (NULL != p); + if (GNUNET_NO == exist_session(p, s)) + return 0; struct HTTP_Message *msg; int bytes_read = 0; @@ -736,6 +746,10 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, return; s = sc->session; + GNUNET_assert (NULL != p); + if (GNUNET_NO == exist_session(p, s)) + return; + plugin = s->plugin; if (sc->direction == _SEND) { @@ -1018,6 +1032,8 @@ server_start (struct Plugin *plugin) { int res = GNUNET_OK; unsigned int timeout; + p = plugin; + GNUNET_assert (NULL != plugin); #if BUILD_HTTPS res = server_load_certificate (plugin); @@ -1150,6 +1166,8 @@ server_stop (struct Plugin *plugin) struct Session *s = NULL; struct Session *t = NULL; + p = NULL; + struct MHD_Daemon *server_v4_tmp = plugin->server_v4; plugin->server_v4 = NULL;