]> Cypherpunks repositories - gostls13.git/commit
net/http/fcgi: fix handling of request ID reuse
authorCatalin Patulea <catalinp@google.com>
Mon, 17 Mar 2014 22:47:16 +0000 (15:47 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 17 Mar 2014 22:47:16 +0000 (15:47 -0700)
commita387f915538abbb6f5661cb39b8fccb606c5ad25
tree312c6e68eff17058e1b5507d5defc6fc818cb626
parentbe60bd090ec8447d2a50b652ae50b3a7df675a38
net/http/fcgi: fix handling of request ID reuse

Request ID reuse is allowed by the FastCGI spec [1]. In particular nginx uses
the same request ID, 1, for all requests on a given connection. Because
serveRequest does not remove the request from conn.requests, this causes it to
treat the second request as a duplicate and drops the connection immediately
after beginRequest. This manifests with nginx option 'fastcgi_keep_conn on' as
the following message in nginx error log:

2014/03/17 01:39:13 [error] 730#0: *109 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: example.org, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "example.org"

Because handleRecord and serveRequest run in different goroutines, access to
conn.requests must now be synchronized.

[1] http://www.fastcgi.com/drupal/node/6?q=node/22#S3.3

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/76800043
src/pkg/net/http/fcgi/child.go