Thanks,
Silvio, it would be great if you could send me that working
code. Probably saves a lot of time :-). My environment is an
openembedded tree, as published by the manufacturer of the
thermostat, back in 2012. Parts of it are really old, so
sometimes I have to do quite some patching to backport newer
code to that tree and toolchain. Nevertheless, your working
code is probably fairly easy to build. libmicrohttpd wasn't so
hard in terms of passing it through this toolchain. Getting it
to work is a different story :-).
In the meantime, I ploughed through a lot of routines, working
my way up from the routines that have
daemon->default_handler (which is called from ozwcp) as
argument.
I have tested
the following options for the server:
MHD_USE_EPOLL |
MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_DEBUG
This ends up
in a race condition in MHD_epoll(), as called in
MHD_polling_thread().
MHD_USE_POLL |
MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_DEBUG
gives a race
condition in MHD_poll()
and finally:
MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_DEBUG
This gives a race condition in MHD_select().
The race conditions at least explain why the client keeps trying, while nothing gets actually loaded. Only after killing the daemon, the connection is reset.
I did some follow-up on the race condition in MHD_select(), and found that the connections in the daemon struct are not filled:
(excerpt from internal_run_from_select() ):
...
(FD_ISSET (ds,
read_fd_set)) )
(void) MHD_accept_connection (daemon);
if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
{
/* do not have a thread per connection, process all connections now */
prev = daemon->connections_tail; <---- prev = 0x00
while (NULL != (pos = prev)) <---- pos is also 0x00, so the loop never starts, resulting in a new call to MHD_select(), and so on and on ..
{
prev = pos->prev;
ds = pos->socket_fd;
...
Both current and previous connections are NULL pointers, which is not good :-(, but it already narrows the issue down to a much smaller part of the daemon. So the next question is: where are these connections filled, and how do I check if it's done properly?