libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] Race condition when enqueing


From: Mike Crowe
Subject: Re: [libmicrohttpd] Race condition when enqueing
Date: Tue, 9 Mar 2010 17:20:47 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

On Tuesday 09 March 2010 05:20:17 pm Mike Crowe wrote:
>> I'm seeing an occasional unit test failure in the code I'm using with
>> libmicrohttpd 0.4.5 when accepting a chunked POST request both with
>> and without the client expecting "100 continue." I'm using
>> MHD_USE_THREAD_PER_CONNECTION mode and I'm setting up the response
>> deliberately even before any body has arrived.

On Tue, Mar 09, 2010 at 06:12:46PM +0100, Christian Grothoff wrote:
> Without having seen your handler function, I suspect that it is (3).  MHD 
> expects you to ONLY queue a response after you've either seen the full 
> request 
> (not the case here) or on the first call when 100 CONTINUE is still being 
> "considered".  Since (based on your description of the type of request that 
> is 
> happening here) 100 CONTINUE is skipped, you need to wait with queuing a 
> response until the entire request was processed.  This was a deliberate 
> design 
> decision since it seemed too messy to have an application give us a response 
> and then continue to process the upload -- this would almost always be a bad 
> idea since you could then not change the response to indicate an error 
> anymore.

I'm certainly doing that. I thought it was supported. It is in fact an
error I'm imparting in the hope that the client will stop sending (by
force if necessary because libmicrohttpd has to close the connection.)
There is even code in MHD_queue_response that appears to cope with
this situation:

  if (connection->state == MHD_CONNECTION_HEADERS_PROCESSED)
    {
      /* response was queued "early",
         refuse to read body / footers or further
         requests! */
      SHUTDOWN (connection->socket_fd, SHUT_RD);
      connection->read_closed = MHD_YES;
      connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
    }

But, irrespective of this I believe I was able to reproduce the same
problem even when "100 CONTINUE" support was requested by the client -
I just didn't investigate that case in any detail. I shall now do so.

Thanks for your quick reply.

Mike.




reply via email to

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