|
From: | Evgeny Grin |
Subject: | Re: [libmicrohttpd] race condition on 0.9.73 |
Date: | Tue, 28 Sep 2021 22:01:37 +0300 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
Hi José, On 28.09.2021 18:44, José Bollo wrote:
Function MHD_run_wait() was added for upcoming version 0.9.74, but it does not return flag "need to re-run". MHD_get_timeout() already serves for this purpose.I finally had time to look at this new function. It can be improved by returning a status telling if something was processed or not instead of just ok/error. This would allow to call it with a timeout of 0 until nothing is done.
It would be easy to implement such kind of loop just inside this function, but the idea of MHD_run_wait() is to avoid locking of all system resources only for HTTP processing, therefore after making full round of processing of all connection, the function returns for any other processing by application.
With fast enough connection (or connections) and slow CPU it is possible that MHD_get_timeout() returns zero for some period of time when data is arriving faster that CPU is able to process it (or the response is being sent faster than the response is being generated). Especially if connection is HTTPS. With MHD_run_wait() you can get some kind fair distribution of CPU time for HTTP processing and for other needs.
It is expected that application may have something to process without locking and return to MHD_run_wait() as soon as other data is processed.
MHD_get_timeout() gives you better indication whether something needs to be processed than flag "something was processed". It would be possible that nothing was processed, but next timeout is zero because some connection has been just expired.
-- Wishes, Evgeny
OpenPGP_signature
Description: OpenPGP digital signature
[Prev in Thread] | Current Thread | [Next in Thread] |