Fixing racing condition in request.msgs usage.

This commit is contained in:
Max Romanov
2017-10-27 11:05:37 +03:00
parent 1d11f8cfbb
commit fa76ea700f

View File

@@ -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
}