libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] block request in per thread model


From: Christian Grothoff
Subject: Re: [libmicrohttpd] block request in per thread model
Date: Sun, 24 Aug 2008 10:16:39 -0600
User-agent: KMail/1.9.9

Hi!

Actually, in per-thread model *you* should block on IO if you need to (we 
don't want to do busy-waiting).  Returning 0 in per-thread model should be 
undefined (if it says otherwise in the documentation somewhere, let me know 
where exactly and I'll fix it).  So in the thread model used by your example 
(one-thread-per connection), you can just block in "file_reader" and wait 
until you have the data for the response. Other HTTP-requests will continue 
while that thread blocks.

If you are in external select mode, then you could return 0 and MHD should 
retry the next time it is invoked (which allows you to block on your IO in 
the external select).

If you are in internal select mode, you cannot "nicely" handle blocking IO 
(all other HTTP-operations will not continue while your handler blocks on IO, 
which maybe ok for low-performance applications or minimal blocking, for 
example on uncontended locks).

I hope this helps!

Christian

On Saturday 23 August 2008 10:29:31 am Wilson Lam Wing Hang wrote:
> Hello,
>  I recently use libmicrohttpd to do a project related to video progressive
> streaming. As mentioned in the documentation, if creating a block
> request, the MHD_ContentReaderCallback could return zero if data is not
> ready. Then, wait for MHD to retry (MHD should retry immediately in per
> thread model) .
>
>  However, while it returns zero, it seems that MHD never tries as the
> document said.
>
>  I have attached an example which is a modified fileserver_example.c. What
> I expected is the MHD will keep retrying the callback until it returns
> -1.
>
>  I am looking forward to some replies which could solve related problem or
> an example for handling block request in MDH.
>
> Thanks in advance.
> Wilson




reply via email to

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