]> Cypherpunks repositories - gostls13.git/commit
net/http/fcgi: fix a shutdown race
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 21 Mar 2013 21:07:24 +0000 (14:07 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 21 Mar 2013 21:07:24 +0000 (14:07 -0700)
commitd7c1f67cb92d29622de35b86288b2c6032285965
treeb9f305a28bfd572db1a6c79a2f06f5edc022438d
parentaafc444b74ba2a4dc56e6d5d26f8242f0857856a
net/http/fcgi: fix a shutdown race

If a handler didn't consume all its Request.Body, child.go was
closing the socket while the host was still writing to it,
causing the child to send a RST and the host (at least nginx)
to send an empty response body.

Now, we tell the host we're done with the request/response
first, and then close our input pipe after consuming a bit of
it. Consuming the body fixes the problem, and flushing to the
host first to tell it that we're done increases the chance
that the host cuts off further data to us, meaning we won't
have much to consume.

No new tests, because this package is lacking in tests.
Tested by hand with nginx.  See issue for testing details.

Fixes #4183

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7939045
src/pkg/net/http/fcgi/child.go