Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CloseNotify race with ServeHTTP #119

Closed
cuongdo opened this issue Mar 2, 2016 · 0 comments
Closed

CloseNotify race with ServeHTTP #119

cuongdo opened this issue Mar 2, 2016 · 0 comments

Comments

@cuongdo
Copy link

cuongdo commented Mar 2, 2016

The following request of the provided example server:

curl http://localhost:8080/v1/example/echo_body -d 'foo'

Causes the following panic:

panic: net/http: CloseNotify called after ServeHTTP finished

goroutine 73 [running]:
panic(0x3fcb00, 0xc8201e2840)
    /usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:464 +0x3e6
net/http.(*response).CloseNotify(0xc8201e0750, 0x0)
    /usr/local/Cellar/go/1.6/libexec/src/net/http/server.go:1535 +0x9d
github.com/gengo/grpc-gateway/examples/examplepb.RegisterEchoServiceHandler.func2.1(0xc8201e2720, 0x98a070, 0xc8201e0750, 0xc8201e2730)
    /Users/cdo/gocode/src/github.com/gengo/grpc-gateway/examples/examplepb/echo_service.pb.gw.go:134 +0x66
created by github.com/gengo/grpc-gateway/examples/examplepb.RegisterEchoServiceHandler.func2
    /Users/cdo/gocode/src/github.com/gengo/grpc-gateway/examples/examplepb/echo_service.pb.gw.go:137 +0x19e
cuongdo pushed a commit to cuongdo/grpc-gateway that referenced this issue Mar 2, 2016
The generated code for the mux handlers can panic if the call to
ServeHTTP() finishes before the goroutine finishes. This is because
CloseNotify() can only be called before ServeHTTP() finishes. I've
fixed this by calling CloseNotify() before starting the goroutine. The
returned channel can safely be selected any time after that.
cuongdo pushed a commit to cuongdo/grpc-gateway that referenced this issue Mar 2, 2016
The generated code for the mux handlers can panic if the call to
ServeHTTP() finishes before the goroutine finishes. This is because
CloseNotify() can only be called before ServeHTTP() finishes. I've
fixed this by calling CloseNotify() before starting the goroutine. The
returned channel can safely be selected any time after that.
@yugui yugui closed this as completed in 03a605b Mar 3, 2016
yugui added a commit that referenced this issue Mar 3, 2016
Fix #119 - CloseNotify race with ServeHTTP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant