Fixing racing condition in request.msgs usage.
@@ -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
}
