Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(123)

Issue 76800043: code review 76800043: net/http/fcgi: fix handling of request ID reuse

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 2 months ago by catalinp
Modified:
11 years, 2 months ago
Reviewers:
bradfitz
CC:
bradfitz, golang-codereviews
Visibility:
Public.

Description

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

Patch Set 1 #

Patch Set 2 : diff -r 32b8c26e4414 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 32b8c26e4414 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 4 : diff -r 32b8c26e4414 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+16 lines, -3 lines) Patch
M src/pkg/net/http/fcgi/child.go View 1 2 3 6 chunks +16 lines, -3 lines 0 comments Download

Messages

Total messages: 5
catalinp
Hello bradfitz@golang.org (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
11 years, 2 months ago (2014-03-17 16:40:53 UTC) #1
bradfitz
Makes sense. Little style nit: https://codereview.appspot.com/76800043/diff/40001/src/pkg/net/http/fcgi/child.go File src/pkg/net/http/fcgi/child.go (right): https://codereview.appspot.com/76800043/diff/40001/src/pkg/net/http/fcgi/child.go#newcode130 src/pkg/net/http/fcgi/child.go:130: mutex sync.Mutex // protects ...
11 years, 2 months ago (2014-03-17 19:02:32 UTC) #2
catalinp
https://codereview.appspot.com/76800043/diff/40001/src/pkg/net/http/fcgi/child.go File src/pkg/net/http/fcgi/child.go (right): https://codereview.appspot.com/76800043/diff/40001/src/pkg/net/http/fcgi/child.go#newcode130 src/pkg/net/http/fcgi/child.go:130: mutex sync.Mutex // protects requests On 2014/03/17 19:02:32, bradfitz ...
11 years, 2 months ago (2014-03-17 20:21:46 UTC) #3
bradfitz
LGTM On Mon, Mar 17, 2014 at 1:21 PM, <catalinp@google.com> wrote: > > https://codereview.appspot.com/76800043/diff/40001/src/ > ...
11 years, 2 months ago (2014-03-17 22:47:14 UTC) #4
bradfitz
11 years, 2 months ago (2014-03-17 22:47:18 UTC) #5
*** Submitted as https://code.google.com/p/go/source/detail?r=c69077fe03a5 ***

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://codereview.appspot.com/76800043

Committer: Brad Fitzpatrick <bradfitz@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b