Skip to content

Commit ea095bc

Browse files
panjf2000neild
authored andcommitted
http2: only set up positive deadlines
Fixes golang/go#65785 Change-Id: Icd95d7cae5ed26b8a2fe656daf8365e27a7785d8 Reviewed-on: https://go-review.googlesource.com/c/net/+/565195 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 8c07e20 commit ea095bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

http2/server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) {
434434
// passes the connection off to us with the deadline already set.
435435
// Write deadlines are set per stream in serverConn.newStream.
436436
// Disarm the net.Conn write deadline here.
437-
if sc.hs.WriteTimeout != 0 {
437+
if sc.hs.WriteTimeout > 0 {
438438
sc.conn.SetWriteDeadline(time.Time{})
439439
}
440440

@@ -2017,7 +2017,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error {
20172017
// similar to how the http1 server works. Here it's
20182018
// technically more like the http1 Server's ReadHeaderTimeout
20192019
// (in Go 1.8), though. That's a more sane option anyway.
2020-
if sc.hs.ReadTimeout != 0 {
2020+
if sc.hs.ReadTimeout > 0 {
20212021
sc.conn.SetReadDeadline(time.Time{})
20222022
st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
20232023
}
@@ -2038,7 +2038,7 @@ func (sc *serverConn) upgradeRequest(req *http.Request) {
20382038

20392039
// Disable any read deadline set by the net/http package
20402040
// prior to the upgrade.
2041-
if sc.hs.ReadTimeout != 0 {
2041+
if sc.hs.ReadTimeout > 0 {
20422042
sc.conn.SetReadDeadline(time.Time{})
20432043
}
20442044

@@ -2116,7 +2116,7 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream
21162116
st.flow.conn = &sc.flow // link to conn-level counter
21172117
st.flow.add(sc.initialStreamSendWindowSize)
21182118
st.inflow.init(sc.srv.initialStreamRecvWindowSize())
2119-
if sc.hs.WriteTimeout != 0 {
2119+
if sc.hs.WriteTimeout > 0 {
21202120
st.writeDeadline = time.AfterFunc(sc.hs.WriteTimeout, st.onWriteTimeout)
21212121
}
21222122

0 commit comments

Comments
 (0)