Skip to content

Commit 7432bee

Browse files
tz70sodeke-em
authored andcommitted
net/http/fcgi: fix race in child.serve connection read
Guards the connection read with a mutex, because typeStdin asynchronously and concurrently writes to the underlying conn. Fixes golang#41167 Change-Id: Ia2610f4fde0bd4b108c54164095ea293980b0301 Reviewed-on: https://go-review.googlesource.com/c/go/+/252417 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
1 parent b246c0e commit 7432bee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/net/http/fcgi/child.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ func (c *child) serve() {
155155
defer c.cleanUp()
156156
var rec record
157157
for {
158+
c.conn.mutex.Lock()
158159
if err := rec.read(c.conn.rwc); err != nil {
160+
c.conn.mutex.Unlock()
159161
return
160162
}
163+
c.conn.mutex.Unlock()
161164
if err := c.handleRecord(&rec); err != nil {
162165
return
163166
}

0 commit comments

Comments
 (0)