[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Issues with multiple connections
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] Issues with multiple connections |
Date: |
Sun, 22 Jun 2014 12:30:45 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 |
Hi again,
Actually, thinking more about this that was a bad fix. Not only
did it require extra locking, but I simply overlooked that we
used to not modify 'response' objects per-connection for a reason:
after all, the response object might be used with HTTP 1.0 and 1.1
connections and those might require different treatment (for example,
1.1 might get a "keep-alive" and 1.0 a "close"). So modifying the
response itself based on what _a_ connection needs is a bad idea.
For "connection: close" MHD addressed that issue by
adding the missing header right into the output buffer of the
connection, instead of modifying the response object. I've
now done the same for "connection: keep-alive" and even
chunked-encoding and content-length headers (as theoretically,
the need for content-length can depend on the HTTP method, and
chunking may also depend on the specifics of the request). Also,
doing all of that in one place makes the code more readable IMO.
Updated fix is in SVN 33743.
Happy hacking!
Christian
On 06/22/2014 12:30 AM, Christian Grothoff wrote:
> Hi!
>
> I've thought about the issue and analyzed the code and found a place
> where a response was modified without locking. This only happens if you
> use a threaded MHD and share a response object among multiple
> connections and rely on MHD to "complete" the header and are unlucky in
> that the response is used by multiple clients before the first one had a
> chance to 'complete' the headers. So that might fit your scenario. I'm
> not sure why it is a regression, except that I think the "Connection:
> Keep-Alive" header specifically might not have been auto-added in 0.9.25
> (and other headers you might have overlooked and/or set yourself and/or
> not hit due to timing issues).
>
> Anyway, I've tried to fix this in SVN 33742, please let me know if this
> fixes your problem.
>
> Happy hacking!
>
> Christian
>
> On 06/20/2014 02:25 PM, Shilpa S wrote:
>> Hello,
>>
>>
>>
>> I have the latest version of microhttps installed and when I try to send
>> POST request on multiple connections, I randomly get a response which looks
>> like this
>>
>>
>>
>> HTTP/1.1 201 Created
>>
>> Connection: Keep-Alive
>>
>> Connection: Keep-Alive
>>
>> Content-Length: 0
>>
>>
>>
>> .....................................
>>
>>
>>
>> or this
>>
>>
>>
>> ......................Connection: Keep-Alive
>>
>> Content-Length: 0
>>
>> Connection: Keep-Alive
>>
>> Content-Length: 0
>>
>>
>>
>> .....................................
>>
>>
>>
>> instead of
>>
>> HTTP/1.1 201 Created
>>
>> Connection: Keep-Alive
>>
>> Content-Length: 0
>>
>> Date: Thu, 19 Jun 2014 18:04:47 GMT
>>
>>
>> Is there something I need to change or do?
>> The version 9.25 was working fine.
>> Please advise.
>>
>> Thanks,
>> Shilpa
>>
>
signature.asc
Description: OpenPGP digital signature