diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-10-27 11:05:37 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-10-27 11:05:37 +0300 |
commit | fa76ea700ff2326c929f9c9f5ff40915a41d0a89 (patch) | |
tree | 08e7dcf33851c7bce61790eea16f0fd2350871cc | |
parent | 1d11f8cfbbc1d991767e005e0ac2b1522d0f907e (diff) | |
download | unit-fa76ea700ff2326c929f9c9f5ff40915a41d0a89.tar.gz unit-fa76ea700ff2326c929f9c9f5ff40915a41d0a89.tar.bz2 |
Fixing racing condition in request.msgs usage.
-rw-r--r-- | src/go/unit/port.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/go/unit/port.go b/src/go/unit/port.go index 6eaa86bb..2dc273fd 100644 --- a/src/go/unit/port.go +++ b/src/go/unit/port.go @@ -206,6 +206,14 @@ func (p *port) read(handler http.Handler) error { r := find_request(c_req) + if len(r.msgs) == 0 { + r.push(m) + } else if r.ch != nil { + r.ch <- m + } else { + m.Close() + } + go func(r *request) { if handler == nil { handler = http.DefaultServeMux @@ -215,13 +223,5 @@ func (p *port) read(handler http.Handler) error { r.done() }(r) - if len(r.msgs) == 0 { - r.push(m) - } else if r.ch != nil { - r.ch <- m - } else { - m.Close() - } - return nil } |