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

net/http: never cancel r.Context() after Hijack #32315

Closed
wants to merge 1 commit into from
Closed

net/http: never cancel r.Context() after Hijack #32315

wants to merge 1 commit into from

Conversation

nhooyr
Copy link
Contributor

@nhooyr nhooyr commented May 29, 2019

Fixes #32314

@googlebot googlebot added the cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change. label May 29, 2019
@gopherbot
Copy link

This PR (HEAD: ba7fc7e) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/179458 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@nhooyr nhooyr changed the title net/http: never ever cancel r.Context() after Hijack net/http: never cancel r.Context() after Hijack May 29, 2019
@gopherbot
Copy link

This PR (HEAD: 902ee3b) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/179458 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

Message from Dave Cheney:

Patch Set 2:

Thank you for this change. Please add a test so this does not regress in the future.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Brad Fitzpatrick:

Patch Set 2: Run-TryBot+1

This looks fine, but do please add a new test.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 2:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=0e59d0ea


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 2:

Build is still in progress...
This change failed on misc-compile-ppc:
See https://storage.googleapis.com/go-build-log/0e59d0ea/misc-compile-ppc_7d7cd769.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Brad Fitzpatrick:

Patch Set 3: Patch Set 2 was rebased


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Brad Fitzpatrick:

Patch Set 3: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 2: TryBot-Result-1

11 of 21 TryBots failed:
Failed on misc-compile-ppc: https://storage.googleapis.com/go-build-log/0e59d0ea/misc-compile-ppc_7d7cd769.log
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/0e59d0ea/freebsd-amd64-12_0_778c6a27.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/0e59d0ea/linux-amd64-race_678e54b0.log
Failed on js-wasm: https://storage.googleapis.com/go-build-log/0e59d0ea/js-wasm_025d3072.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/0e59d0ea/linux-386_6585774f.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/0e59d0ea/openbsd-amd64-64_668e4c1a.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/0e59d0ea/android-amd64-emu_48b43bc0.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/0e59d0ea/linux-amd64_757671f4.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/0e59d0ea/windows-386-2008_28cf60b2.log
Failed on nacl-amd64p32: https://storage.googleapis.com/go-build-log/0e59d0ea/nacl-amd64p32_59bfdd06.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/0e59d0ea/windows-amd64-2016_a9db0cb9.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 3:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=f804102c


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 3:

Build is still in progress...
This change failed on openbsd-amd64-64:
See https://storage.googleapis.com/go-build-log/f804102c/openbsd-amd64-64_f935d8de.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 3: TryBot-Result-1

10 of 21 TryBots failed:
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/f804102c/openbsd-amd64-64_f935d8de.log
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/f804102c/freebsd-amd64-12_0_1b5b4907.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/f804102c/linux-amd64_30ea417c.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/f804102c/android-amd64-emu_47129a8d.log
Failed on js-wasm: https://storage.googleapis.com/go-build-log/f804102c/js-wasm_f5c1bb51.log
Failed on nacl-amd64p32: https://storage.googleapis.com/go-build-log/f804102c/nacl-amd64p32_4c40dd60.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/f804102c/linux-386_3225a1af.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/f804102c/linux-amd64-race_cfe90240.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/f804102c/windows-386-2008_5276b573.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/f804102c/windows-amd64-2016_f877e6e4.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 3:

Patch Set 2: Run-TryBot+1

This looks fine, but do please add a new test.

Anmol, perhaps https://play.golang.org/p/xFSvh6j_h7F might be a test for you or inlined below:

package main

import (
"context"
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
"testing"
)

func TestConnCloseNoReqCancellation(t *testing.T) {
cst := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hj, ok := w.(http.Hijacker)
defer func() {
ctx := r.Context()
select {
case <-ctx.Done():
if err := ctx.Err(); err == context.Canceled {
t.Fatalf("client.Context was canceled: %v", err)
}
default:
}
}()
if !ok {
w.WriteHeader(http.StatusNotImplemented)
return
}
conn, bufrw, err := hj.Hijack()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
conn.Close()

	_, _ = ioutil.ReadAll(bufrw)
	bufrw.Write([]byte("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nContent-Length: 2\r\n\r\nok"))
	bufrw.Flush()
}))
defer cst.Close()

req, _ := http.NewRequest("POST", cst.URL, strings.NewReader("aaaaaaa*****aaaaaaaaaaaa"))
res, _ := cst.Client().Do(req)
if res != nil {
	_, _ = ioutil.ReadAll(res.Body)
	_ = res.Body.Close()
}

}


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

This PR (HEAD: 1d106b4) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/179458 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

This PR (HEAD: 14b4712) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/179458 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

Message from Anmol Sethi:

Patch Set 4:

I have added a test.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Emmanuel Odeke:

Patch Set 5: Run-TryBot+1

(10 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 5:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=43576df4


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 5:

Build is still in progress...
This change failed on js-wasm:
See https://storage.googleapis.com/go-build-log/43576df4/js-wasm_3ba650b2.log

Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Gobot Gobot:

Patch Set 5: TryBot-Result-1

10 of 21 TryBots failed:
Failed on js-wasm: https://storage.googleapis.com/go-build-log/43576df4/js-wasm_3ba650b2.log
Failed on openbsd-amd64-64: https://storage.googleapis.com/go-build-log/43576df4/openbsd-amd64-64_94326e90.log
Failed on freebsd-amd64-12_0: https://storage.googleapis.com/go-build-log/43576df4/freebsd-amd64-12_0_bb59c9eb.log
Failed on linux-amd64: https://storage.googleapis.com/go-build-log/43576df4/linux-amd64_c2781c84.log
Failed on nacl-amd64p32: https://storage.googleapis.com/go-build-log/43576df4/nacl-amd64p32_fff810d7.log
Failed on linux-386: https://storage.googleapis.com/go-build-log/43576df4/linux-386_306fd352.log
Failed on android-amd64-emu: https://storage.googleapis.com/go-build-log/43576df4/android-amd64-emu_fa5006a8.log
Failed on linux-amd64-race: https://storage.googleapis.com/go-build-log/43576df4/linux-amd64-race_91a7cf71.log
Failed on windows-386-2008: https://storage.googleapis.com/go-build-log/43576df4/windows-386-2008_bf0f3f08.log
Failed on windows-amd64-2016: https://storage.googleapis.com/go-build-log/43576df4/windows-amd64-2016_021daed4.log

Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.


Please don’t reply on this GitHub thread. Visit golang.org/cl/179458.
After addressing review feedback, remember to publish your drafts!

@nhooyr
Copy link
Contributor Author

nhooyr commented Jun 11, 2019

@odeke-em feel free to take over, I don't have the time to respond to the reviews

@nhooyr nhooyr closed this Jun 11, 2019
@odeke-em
Copy link
Member

odeke-em commented Jun 11, 2019 via email

@odeke-em
Copy link
Member

odeke-em commented Jun 11, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Used by googlebot to label PRs as having a valid CLA. The text of this label should not change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

net/http: reading from hijacked bufio.Reader should not cause r.Context to be cancelled
4 participants