summaryrefslogtreecommitdiffhomepage
path: root/src/go
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2017-10-27 11:05:37 +0300
committerMax Romanov <max.romanov@nginx.com>2017-10-27 11:05:37 +0300
commitfa76ea700ff2326c929f9c9f5ff40915a41d0a89 (patch)
tree08e7dcf33851c7bce61790eea16f0fd2350871cc /src/go
parent1d11f8cfbbc1d991767e005e0ac2b1522d0f907e (diff)
downloadunit-fa76ea700ff2326c929f9c9f5ff40915a41d0a89.tar.gz
unit-fa76ea700ff2326c929f9c9f5ff40915a41d0a89.tar.bz2
Fixing racing condition in request.msgs usage.
Diffstat (limited to 'src/go')
-rw-r--r--src/go/unit/port.go16
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
}