libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Clarification on receiving on one thread, replying o


From: Christian Grothoff
Subject: Re: [libmicrohttpd] Clarification on receiving on one thread, replying on another
Date: Mon, 24 Oct 2016 23:16:05 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 10/24/2016 10:13 PM, Tom Cornell wrote:
> 
> Generating a response requires forwarding another request off to 
> a different web service, and then possibly waiting a while for that
> service to respond to us, so we can respond to our client. I'm looking
> at different ways to avoid tying up an MHD thread while waiting for
> that response. External select is an obvious choice, but I was 
> thinking I could get away with using internal select as well. Looks
> like a "no". The work could be done on another thread and signaled
> back to the MHD thread, but the latter would still be stuck waiting
> for that signal, since it can't return from the access handler
> until it has queued the response.

The latter is incorrect. You can totally return from the access handler
without queueing a response. Simply return "MHD_YES".  MHD will call you
again "immediately" in this case (next iteration of event loop). To
avoid busy waiting, suspend the connection.  Then resume it whenever you
have the response ready, wait to be called again, then give MHD the
now-ready response.



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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