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.
signature.asc
Description: OpenPGP digital signature
