libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 9562d1656d683cce2a2557fc0c2e5573fabfc6bb
parent e76b3a78104ab4d6b939a50fe1de446b34296916
Author: Christian Grothoff <christian@grothoff.org>
Date:   Thu, 15 Feb 2018 07:24:35 +0100

implement request_resume

Diffstat:
Msrc/lib/connection_add.c | 2+-
Msrc/lib/daemon_epoll.c | 2+-
Msrc/lib/daemon_poll.c | 2+-
Msrc/lib/daemon_select.c | 2+-
Msrc/lib/internal.h | 5+++++
Msrc/lib/request_resume.c | 19++++++++++++++++++-
6 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/lib/connection_add.c b/src/lib/connection_add.c @@ -369,7 +369,7 @@ thread_main_handle_connection (void *data) * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ - MHD_resume_connection (con); + MHD_request_resume (&con->request); /* skip usual clean up */ return (MHD_THRD_RTRN_TYPE_) 0; diff --git a/src/lib/daemon_epoll.c b/src/lib/daemon_epoll.c @@ -188,7 +188,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) * will be moved immediately to cleanup list. Otherwise * connection will stay in suspended list until 'pos' will * be marked with 'was_closed' by application. */ - MHD_resume_connection (pos->connection); + MHD_request_resume (&pos->connection->request); } } diff --git a/src/lib/daemon_poll.c b/src/lib/daemon_poll.c @@ -326,7 +326,7 @@ MHD_daemon_poll_all_ (struct MHD_Daemon *daemon, * moved immediately to cleanup list. Otherwise connection * will stay in suspended list until 'urh' will be marked * with 'was_closed' by application. */ - MHD_resume_connection(urh->connection); + MHD_request_resume (&urh->connection->request); } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ diff --git a/src/lib/daemon_select.c b/src/lib/daemon_select.c @@ -468,7 +468,7 @@ internal_run_from_select (struct MHD_Daemon *daemon, MHD_connection_finish_forward_ (urh->connection); urh->clean_ready = true; /* Resuming will move connection to cleanup list. */ - MHD_resume_connection(urh->connection); + MHD_request_resume (&urh->connection->request); } } #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ diff --git a/src/lib/internal.h b/src/lib/internal.h @@ -1542,6 +1542,11 @@ struct MHD_Daemon bool was_quiesced; /** + * Is some connection wanting to resume? + */ + bool resuming; + + /** * Allow reusing the address:port combination when binding. * See #MHD_daemon_listen_allow_address_reuse(). */ diff --git a/src/lib/request_resume.c b/src/lib/request_resume.c @@ -42,7 +42,24 @@ void MHD_request_resume (struct MHD_Request *request) { - abort (); // not implemented... + struct MHD_Daemon *daemon = request->daemon; + + if (daemon->disallow_suspend_resume) + MHD_PANIC (_("Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n")); + MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex); + request->connection->resuming = true; + daemon->resuming = true; + MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); + if ( (MHD_ITC_IS_VALID_(daemon->itc)) && + (! MHD_itc_activate_ (daemon->itc, + "r")) ) + { +#ifdef HAVE_MESSAGES + MHD_DLOG (daemon, + MHD_SC_ITC_USE_FAILED, + _("Failed to signal resume via inter-thread communication channel.")); +#endif + } } /* end of request_resume.c */