summaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_server.c
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amat.us>2017-06-12 23:50:25 -0500
committerDavid Barksdale <amatus@amat.us>2017-06-12 23:50:25 -0500
commit1fc3df9be3dd51b14f752ea1a9e623aa781192bd (patch)
tree1c67370d6c7d3322cdaa522511a260c2a3bc14b5 /src/transport/plugin_transport_http_server.c
parent4b32469e56fd7751165574ad2b13ee0ef7efad31 (diff)
[transport] suspend connection to avoid busy-wait
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r--src/transport/plugin_transport_http_server.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index ff2d68602..e3d5e9a01 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -92,6 +92,11 @@ struct ServerRequest
*/
int connected;
+ /**
+ * Currently suspended
+ */
+ bool suspended;
+
};
@@ -501,7 +506,9 @@ server_wake_up (void *cls)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Session %p: Waking up PUT handle\n",
s);
+ GNUNET_assert (s->server_recv->suspended);
MHD_resume_connection (s->server_recv->mhd_conn);
+ s->server_recv->suspended = false;
}
@@ -541,7 +548,11 @@ server_delete_session (struct GNUNET_ATS_Session *s)
GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
s->recv_wakeup_task = NULL;
if (NULL != s->server_recv)
+ {
+ GNUNET_assert (s->server_recv->suspended);
MHD_resume_connection (s->server_recv->mhd_conn);
+ s->server_recv->suspended = false;
+ }
}
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
@@ -760,9 +771,16 @@ http_server_plugin_send (void *cls,
GNUNET_free (stat_txt);
if (NULL != session->server_send)
+ {
+ if (session->server_send->suspended)
+ {
+ MHD_resume_connection (session->server_send->mhd_conn);
+ session->server_send->suspended = false;
+ }
server_reschedule (session->plugin,
session->server_send->mhd_daemon,
GNUNET_YES);
+ }
return bytes_sent;
}
@@ -1613,6 +1631,12 @@ server_send_callback (void *cls,
s);
return MHD_CONTENT_READER_END_OF_STREAM;
}
+ else
+ {
+ MHD_suspend_connection (s->server_send->mhd_conn);
+ s->server_send->suspended = true;
+ return 0;
+ }
return bytes_read;
}
@@ -1868,6 +1892,7 @@ server_access_cb (void *cls,
GNUNET_YES));
GNUNET_assert(s->server_recv->mhd_conn == mhd_connection);
MHD_suspend_connection (s->server_recv->mhd_conn);
+ s->server_recv->suspended = true;
if (NULL == s->recv_wakeup_task)
s->recv_wakeup_task
= GNUNET_SCHEDULER_add_delayed (delay,