提交 4c02c982 作者: Jeromy Johnson

Merge pull request #2315 from rwcarlsen/fix-closenotify-panic

fix go1.6rc2 panic where closenotify was called from wrong goroutine
...@@ -138,9 +138,10 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -138,9 +138,10 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithCancel(node.Context()) ctx, cancel := context.WithCancel(node.Context())
defer cancel() defer cancel()
if cn, ok := w.(http.CloseNotifier); ok { if cn, ok := w.(http.CloseNotifier); ok {
clientGone := cn.CloseNotify()
go func() { go func() {
select { select {
case <-cn.CloseNotify(): case <-clientGone:
case <-ctx.Done(): case <-ctx.Done():
} }
cancel() cancel()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论