libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Suspending/resuming not working with external select


From: Johannes Spangenberg
Subject: Re: [libmicrohttpd] Suspending/resuming not working with external select
Date: Mon, 5 Sep 2016 01:20:14 +0000

Thank you, Christian.

Your fix did work for me. In my small example, and in my other program, 
too. I already discovered that I missed FD_ZERO and max=0 but since it 
did not fix the bug, I have not send a mail about it. I wrote that the 
second request was never accepted. After reading your mail, I figured 
out that it is not true for curl. Firefox simply did not send the second 
request. Maybe firefox has tied to reuse the connection or it did 
combine both request for the same resource.

As a feature request: I would suggest that MHD_get_fdset() calls 
resume_suspended_connections(). Then, it could do the work which is 
necessary to get the right fd_sets. It looks a little bit strange to me 
that I have to call MHD_run() with all it's overhead of calling select() 
and handling requests. This way, the application would also not need to 
track it's calls to MHD_resume_connection() to know whether it has to 
call this function. Another possibility would be a new function that can 
be called before calling MHD_get_fdset(). Another problem of the current 
implementation is that MHD_run_from_select() does never call 
resume_suspended_connections() while using epoll when there is no IO 
activity. The reason is that the function is called in MHD_epoll() which 
is not called without IO activity. I think the API could be improved 
there if it is not to difficult to implement.

Again, thank you for your help.
Johannes


Am 04.09.2016 um 17:53 schrieb Christian Grothoff:
> Dear Johannes,
>
> You need to run "MHD_run()" between resuming and asking for the FD set.
> It was not very well documented, so I've fixed the documentation in SVN
> 37877.
>
> You also didn't FD_ZERO your fdsets, but that's minor.  I've attached
> your code with my changes, so that it works.
>
> Happy hacking!
>
> Christian
>
> On 09/04/2016 03:49 PM, Johannes Spangenberg wrote:
>> Hello,
>>
>> I encountered some problems while using the libmicrohttpd. I was using
>> MHD_suspend_connection() and MHD_resume_connection() in combination with
>> an external event loop. The problem was that the connection was not
>> resumed until another request was made. I checked the event loop but
>> they was running and calling MHD_run_with_select() periodically.
>> Afterwards, I wrote a small test program, attached to this mail, to
>> check if it is a bug or misunderstanding of the library. I also tested
>> it agains the last version (0.9.51).
>>
>> Connections are still not resumed in the small test program. But in
>> difference to my original project, receiving another request does not
>> resume the first connection. The second request is never accepted by
>> libmicrohttpd. It seems that select() does not return to acceppt the
>> second connection after calling MHD_suspend_connection() on the first
>> one. If I'm not calling MHD_suspend_connection() and
>> MHD_resume_connection(), everythink works. Futuremore, if I am using
>> MHD_USE_SELECT_INTERNALLY and replace the external loop with a busy
>> loop, everything works as well. I thinks it looks like there is a bug in
>> MHD_suspend_connection() and MHD_resume_connection() when used with
>> external select. Could someone take a look and check whether I'm doing
>> something wrong or there is a bug in the library.
>>
>> I searchd for it but could not find a solution to fix it. A found
>> another conversation in the mailing list: [MHD_suspend_connection
>> API](http://lists.gnu.org/archive/html/libmicrohttpd/2014-02/msg00005.html).
>> It is not clear but thing it may be possible that he stumbled over the
>> same bug.
>>
>> My english is not the best but I hope you can understand everything.
>> Johannes
>>


reply via email to

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