mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/http/cgi: Remove hard-coded ServeHTTP timeout
Close #43624
Change-Id: Ifaea3d8ec2aeabbd923abf5edd7497172dbf855a
GitHub-Last-Rev: ea3ef953a1
GitHub-Pull-Request: golang/go#43803
Reviewed-on: https://go-review.googlesource.com/c/go/+/284778
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
492eb059f9
commit
c1e8a9a8c6
1 changed files with 3 additions and 26 deletions
|
|
@ -95,12 +95,6 @@ func (w *limitWriter) Write(p []byte) (n int, err error) {
|
||||||
func TestKillChildAfterCopyError(t *testing.T) {
|
func TestKillChildAfterCopyError(t *testing.T) {
|
||||||
testenv.MustHaveExec(t)
|
testenv.MustHaveExec(t)
|
||||||
|
|
||||||
defer func() { testHookStartProcess = nil }()
|
|
||||||
proc := make(chan *os.Process, 1)
|
|
||||||
testHookStartProcess = func(p *os.Process) {
|
|
||||||
proc <- p
|
|
||||||
}
|
|
||||||
|
|
||||||
h := &Handler{
|
h := &Handler{
|
||||||
Path: os.Args[0],
|
Path: os.Args[0],
|
||||||
Root: "/test.go",
|
Root: "/test.go",
|
||||||
|
|
@ -112,26 +106,9 @@ func TestKillChildAfterCopyError(t *testing.T) {
|
||||||
const writeLen = 50 << 10
|
const writeLen = 50 << 10
|
||||||
rw := &customWriterRecorder{&limitWriter{&out, writeLen}, rec}
|
rw := &customWriterRecorder{&limitWriter{&out, writeLen}, rec}
|
||||||
|
|
||||||
donec := make(chan bool, 1)
|
h.ServeHTTP(rw, req)
|
||||||
go func() {
|
if out.Len() != writeLen || out.Bytes()[0] != 'a' {
|
||||||
h.ServeHTTP(rw, req)
|
t.Errorf("unexpected output: %q", out.Bytes())
|
||||||
donec <- true
|
|
||||||
}()
|
|
||||||
|
|
||||||
select {
|
|
||||||
case <-donec:
|
|
||||||
if out.Len() != writeLen || out.Bytes()[0] != 'a' {
|
|
||||||
t.Errorf("unexpected output: %q", out.Bytes())
|
|
||||||
}
|
|
||||||
case <-time.After(5 * time.Second):
|
|
||||||
t.Errorf("timeout. ServeHTTP hung and didn't kill the child process?")
|
|
||||||
select {
|
|
||||||
case p := <-proc:
|
|
||||||
p.Kill()
|
|
||||||
t.Logf("killed process")
|
|
||||||
default:
|
|
||||||
t.Logf("didn't kill process")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue