libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] More useful MHD_quiesce_daemon in threaded mode


From: Milan Straka
Subject: [libmicrohttpd] More useful MHD_quiesce_daemon in threaded mode
Date: Mon, 27 Oct 2014 17:13:57 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi all,

I am from Charles University in Prague and I am using libmicrohttpd as
HTTP server in several RESTful services provided by our department
(linguistics, for example http://lindat.mff.cuni.cz/services/morphodita/).
I use MHD_USE_THREAD_PER_CONNECTION | MHD_USE_POLL and need to continue
using some threaded mode (the services response takes quite some time to
compute).

I am now facing an issue how to upgrade the running service seamlessly.
I need to stop listening on the socket, wait reasonable time for the
requests being served to finish, and stop.

Nevertheless, as stated in the documentation, the MHD_select_thread(s)
still has the listening socket after MHD_quiesce_daemon and can accept
one incoming connection at any time.

I believe it would be better to stop the MHD_select_thread(s) in the
MHD_quesce_daemon. That would allow to return the listening FD which
would no longer be referenced anywhere in the daemon, making sure that
no more connections are accepted and allowing user to manipulate the FD
as they see fit. This behaviour is actually the one I was expecting when
discovering MHD_quiesce_daemon.

I think the patch would be simple -- you could just kill the threads
in the MHD_quiesce_daemon. Or, if you do not like that, you could
make the MHD_select_thread(s) exit not only if daemon->shutdown, but
also if daemon->socket_fd == MHD_INVALID_SOCKET, and use wpipe at the
end of MHD_quiesce_daemon to wake them up and pthread_join them.
(Opened wpipe would be needed, but there are already some (not really
needed) tests for opened wpipe in MHD_USE_SELECT_INTERNALLY at the
beginning of MHD_quiesce_daemon.)

Cheers,
Milan Straka



reply via email to

[Prev in Thread] Current Thread [Next in Thread]