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: José Bollo
Subject: Re: [libmicrohttpd] race condition on 0.9.73
Date: Fri, 24 Sep 2021 18:22:11 +0200

Hi Evgeny,

Seems fixed on my side. I enforced single call of MHD_run. But I added
a special treatment to enforce call to MHD_run even if MHD_get_timeout
returned a timeout different of zero.

This last point was discussed in the ML thread
https://lists.gnu.org/archive/html/libmicrohttpd/2020-12/msg00017.html

It could be of great advantage that MHD_get_timeout returns valuable
value and also to have a version of MHD_run with a timeout (0 in my
case) and returning a value indicating if it has to be called again for
pending actions.

Thank you for your help.

Best regards
José


On Fri, 24 Sep 2021 14:56:36 +0200
José Bollo <jobol@nonadev.net> wrote:

> Hi Evgeny, Hi all,
> 
> Firstly, protecting MHD_run made the job, the crash disappears and
> valgrind is happy. Thank you for that efficient support.
> 
> Secundly, I'm still seeing and investigating an issue. Sometime, the
> queued response (MHD_queue_response) is not sent. Here again, I think
> that it is a race condition. The issue is surely on my side.
> 
> Then some responses to your questions below.
> 
> [snip]
> 
> > >>>
> > >>>         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?    
> > > 
> > > yes for websocket upgrade but it is not relevant in the case.    
> > 
> > Don't you use MHD built-in "upgrade" functions?  
> 
> Good question. I had not noticed before: I have both options
> MHD_ALLOW_UPGRADE and MHD_ALLOW_SUSPEND_RESUME. When I first
> implemented websocket using MHD, I used the suspend/resume behaviour.
> Is it still needed? I am now using MHD_create_response_for_upgrade for
> that purpose.
> 
> However, at the moment, the program suspend the connection for the
> time it processes the request. That is the reason way MHD_run were
> called from multiple threads.
> 
> [snip]
> 
> > Please share you results.
> > We are close to releasing the next MHD version and want to make
> > sure there are no know bugs in the code.  
> 
> Still investigating one issue.
> 
> > I'm wondering, why do you run the same MHD instance in different
> > threads? Every MHD_run() processes *all* connections served by
> > particular MHD instance. This looks like work duplication (or
> > multiplication). If you process specific connections by each thread
> > and you add connections to MHD by MHD_add_connection(), just use
> > thread-specific MHD instance so you will always know which
> > connections are processed by MHD_run().  
> 
> I could answer but here is what I prefer to write.
> 
> I also think that if every one made same choices the world would be
> peaceful. But new problems, new solutions, new men, new ideas, ... Why
> have you written MHD in C and not in PASCAL?
> 




reply via email to

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