libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Busy waiting up to one second using connection timeo


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Busy waiting up to one second using connection timeout
Date: Wed, 11 Aug 2021 22:39:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

Thanks for the detailed report, the patch looks good as-is, applied to
master as

f5d387df7e7fb8de1a5dd0739ddb83a8b19fe64b

Happy hacking!

Christian

On 8/11/21 6:02 PM, Irion, Alexander wrote:
> Hello!
> 
> I discovered a problem with closing connections, when
> MHD_OPTION_CONNECTION_TIMEOUT is used. When I set the timeout option to
> 3 seconds and connect with a browser, I get a timeout value from
> MHD_get_timeout() of 3000 ms returned. I then sleep the desired time and
> call MHD_run again(). Then, MHD_get_timeout() returns repetitive a
> timeout of 0 which causes thousands of calls to MHD_run(), taking up
> several hundred milliseconds and burning CPU time.
> 
> I use an external event loop with MHD_DAEMON_INFO_EPOLL_FD.
> 
> As reason I found that the condition  timeout <
> (MHD_monotonic_sec_counter () - connection->last_activity) will not be
> true, after waiting the timeout time. The right side will be equal to
> timeout, so the connection is not closed, MHD_get_timeout() continues to
> return a timeout value of 0, and this runs repetitively in a loop for
> some thousand iterations, until the time jumps to the next second.
> 
> In the attachment please find a small patch for fixing this issue. It's
> just turning the < into a <=.
> 
> Regards,
> Alexander Irion
> -->
> 
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201,
> 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer:
> Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München;
> Registergericht München, HRB 106955
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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