Commit 370af48b authored by AlexStocks's avatar AlexStocks

set default CompressType for tcpconn

parent 450e6da2
...@@ -247,6 +247,7 @@ func (t *gettyTCPConn) SetCompressType(c CompressType) { ...@@ -247,6 +247,7 @@ func (t *gettyTCPConn) SetCompressType(c CompressType) {
default: default:
panic(fmt.Sprintf("illegal comparess type %d", c)) panic(fmt.Sprintf("illegal comparess type %d", c))
} }
t.compress = c
} }
// tcp connection read // tcp connection read
...@@ -257,7 +258,7 @@ func (t *gettyTCPConn) read(p []byte) (int, error) { ...@@ -257,7 +258,7 @@ func (t *gettyTCPConn) read(p []byte) (int, error) {
length int length int
) )
if t.rTimeout > 0 { if t.compress == CompressNone && t.rTimeout > 0 {
// Optimization: update read deadline only if more than 25% // Optimization: update read deadline only if more than 25%
// of the last read deadline exceeded. // of the last read deadline exceeded.
// See https://github.com/golang/go/issues/15133 for details. // See https://github.com/golang/go/issues/15133 for details.
...@@ -353,6 +354,7 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn { ...@@ -353,6 +354,7 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn {
wTimeout: netIOTimeout, wTimeout: netIOTimeout,
local: localAddr, local: localAddr,
peer: peerAddr, peer: peerAddr,
compress: CompressNone,
}, },
} }
conn.EnableWriteCompression(false) conn.EnableWriteCompression(false)
...@@ -372,6 +374,7 @@ func (w *gettyWSConn) SetCompressType(c CompressType) { ...@@ -372,6 +374,7 @@ func (w *gettyWSConn) SetCompressType(c CompressType) {
default: default:
panic(fmt.Sprintf("illegal comparess type %d", c)) panic(fmt.Sprintf("illegal comparess type %d", c))
} }
w.compress = c
} }
func (w *gettyWSConn) handlePing(message string) error { func (w *gettyWSConn) handlePing(message string) error {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment