libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] hung up sockets cause endless loop


From: Christian Grothoff
Subject: Re: [libmicrohttpd] hung up sockets cause endless loop
Date: Tue, 24 Jun 2014 08:11:16 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.6.0

Hi Pawel,

Let's start with the usual question: which MHD version? There was
somewhat recently a fix with respect to HTTPS-clients.

Also, if you just return MHD_YES and never provide a response, then
how do you expect MHD to terminate?  You'd either need to set a timeout
for the request or return MHD_NO for MHD to shutdown a connection.  So
this sounds more like an issue on your end than on MHD's side.  Note
that if MHD calls you a second time with "*upload_data_size == 0",
that's a signal that the client won't send more data. So then you must
either suspend the connection, provide a response or return MHD_NO,
otherwise you WILL by design end up in a loop (ok, depending a bit on
threading model).

Happy hacking!

Christian

On 06/24/2014 06:05 AM, Pawel Veselov wrote:
> Hi.
> 
> I have this problem with my handler being called endlessly if the socket
> was closed in some (I guess), unfriendly way on the remote side.
> 
> My logic, in general, is to always set *upload_data_size to 0, and return
> MHD_YES. In this case, I see myself being called over and over again. There
> are at least 3 active context (I print its %p)
> 
> The strace shows this in the loop (the write is the output from my handler,
> *upload_data_size is always 0 at the time of the callback)
> 
> 907   poll([{fd=5, events=POLLIN}, {fd=16, events=0}, {fd=15, events=0},
> {fd=14, events=0}], 4, 4294967295) = 1 ([{fd=15, revents=POLLERR|POLLHUP}])
> 907   write(2, "HTTP POST /r/0/0, 0 bytes, (nil)"..., 52) = 52
> 907   write(2, "Skipping input chunk 0, because "..., 58) = 58
> 907   write(2, "HTTP POST /r/0/0, 0 bytes, (nil)"..., 52) = 52
> 907   write(2, "Skipping input chunk 0, because "..., 58) = 58
> 907   write(2, "HTTP POST /r/0/0, 0 bytes, (nil)"..., 52) = 52
> 907   write(2, "Skipping input chunk 0, because "..., 58) = 58
> 
> Am I missing checking on some property, and returning MHD_NO as a result?
> 
> Thank you,
>   Pawel.
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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