Thanks for report! Yes, MHD_get_fdset2() do not handle situation with thread pool as it designed to be called from user code only for daemons running external select. Fixed in master by return always MHD_NO for daemons with internal select()/poll()/epoll. Also now MHD_run() and MHD_run_from_select() always return errors too for such daemons.
To make it clear: if you start MHD with any option of MHD_USE_SELECT_INTERNALLY, MHD_USE_POLL_INTERNALLY, MHD_USE_EPOLL_INTERNALLY or MHD_USE_THREAD_PER_CONNECTION then MHD will start internal thread(s) and will automatically process incoming connection with callbacks to user code. You can't use MHD_get_fdset2(), MHD_get_fdset(), MHD_run(), MHD_run_from_select() as MHD is already running in other thread. Note that MHD_OPTION_THREAD_POOL_SIZE require usage of internal threads. -- Best Wishes, Evgeny Grin On 15.03.2017 12:57, Vitaliy T wrote: > Seems to be I have found the root of the problem. > > When I call MHD_get_fdset2() the values are next: > > 1. daemon->epoll_fd == -1 (as I said before). > 2. daemon->worker_pool[0].epoll_fd == 7 (as it was set initially). > > Someone should fix this, because at the moment I don't know how to do > this correctly. >