libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] race condition on 0.9.73


From: Evgeny Grin
Subject: Re: [libmicrohttpd] race condition on 0.9.73
Date: Thu, 23 Sep 2021 19:57:23 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0



On 23.09.2021 18:43, José Bollo wrote:
For sure you can run MHD with "external poll" mode, but you must
ensure that only single thread is calling MHD_run() at any given
moment of time.

Okay, that is a good hint, thanks. I'm going to first track concurrent
use of MHD_run. FYI, I tried the latest git and got the same issue.

If you want to call several copies of MHD_run(), make sure that you
have individual copies of MHD for each thread (start MHD by
MHD_start_daemon() for every thread).

I don't want that, because it implies differents port I suppose.

Even if MHD is doing internal accept(), you still can use MHD_OPTION_LISTENING_ADDRESS_REUSE parameter to bind to the same port. Or provide your own socket. However as I can see below, it's not applicable for your case as you are not using MHD to listen for new connections.


Alternatively, you can use MHD with its own threading mode. MHD can
run treads per connection or use thread pool.

Can you give more details how you use MHD? Which flags are used?

        flags = MHD_USE_EPOLL
                        | MHD_ALLOW_UPGRADE
                        | MHD_USE_TCP_FASTOPEN
                        | MHD_USE_NO_LISTEN_SOCKET
                        | MHD_ALLOW_SUSPEND_RESUME;

Do you use suspend/resume of connections?


Why do you use external threads instead of MHD internal treads?

The program has a job scheduler that manages threads on its own. It
also serves other protocols that HTTP(S).

It is still hard to see where is the problem. Actually responses are thread-safe and shouldn't create any such kind of problems.

Could you share you access handler callback code?
Where do you generate responses?
Where do you queue responses?

--
Evgeny

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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