[Top][All Lists]

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

Re: [libmicrohttpd] Problem destroying response objects

From: Christian Grothoff
Subject: Re: [libmicrohttpd] Problem destroying response objects
Date: Fri, 13 Mar 2009 14:27:13 -0600
User-agent: KMail/1.9.9

The documentation says that the callback must return "-1" to indicate the end 
of the transfer; if you are not returning -1, MHD will keep the connection 
open -- and if you are not sending any data, it won't detect that the other 
side might have closed it (that is only detected when we try to write to the 

The suggested way to terminate these types of connections where clients fail 
to read from the socket is to use a timeout (use 
MHD_OPTION_CONNECTION_TIMEOUT); that will close idle connections and should 
then also destroy the response objects.

Finally, I'm not sure what you mean by "broken pipe" error being reported; MHD 
typically installs a handler for SIGPIPE to catch and ignore those signals...


On Friday 13 March 2009 12:40:49 pm Jon Nalley wrote:
> Hi,
> I am using libmicrohttpd to handle "Comet/Ajax long poll requests".  My
> client establishes a connection to libmicrohttpd and a response object
> is created using MHD_create_response_from_callback().  The response
> callback returns zero bytes until data is available for the client.
> At that time, the callback answers the request.  This allows the
> client to receive data only when the server has something to send.
> The problem that I am observing is that the response object doesn't
> seem to be destroyed when a client disconnects.  The response object
> is repeatedly invoked (during every MHD_run()) whether the client is
> connected or not.  The response object is freed if the callback
> returns -1 or more than zero bytes, and a "Broken pipe" error is
> reported.  It seems that some notification needs to occur when a
> client disconnects to destroy outstanding response objects associated
> with the connection.  Any ideas on how I might accomplish this?
> Regards,
> Jon Nalley
> _______________________________________________
> libmicrohttpd mailing list
> address@hidden

Christian Grothoff
Assistant Professor
Department of Computer Science
University of Denver

reply via email to

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