mirror of https://github.com/gorilla/websocket.git
Merge pull request #8 from smith-30/feature/remove_dict_lock
mod: remove mutex.
This commit is contained in:
commit
bf99740cc4
15
conn.go
15
conn.go
|
@ -267,7 +267,6 @@ type Conn struct {
|
||||||
contextTakeover bool
|
contextTakeover bool
|
||||||
txDict []byte
|
txDict []byte
|
||||||
rxDict []byte
|
rxDict []byte
|
||||||
mutex sync.RWMutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
|
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
|
||||||
|
@ -1168,13 +1167,8 @@ func (c *Conn) SetCompressionLevel(level int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTxDict adds payload to txDict.
|
||||||
func (c *Conn) AddTxDict(b []byte) {
|
func (c *Conn) AddTxDict(b []byte) {
|
||||||
c.mutex.Lock()
|
|
||||||
defer c.mutex.Unlock()
|
|
||||||
|
|
||||||
// Todo I do not know whether to leave the dictionary with 32768 bytes or more
|
|
||||||
// If it is recognized as a duplicate character string,
|
|
||||||
// deleting a part of the character may make it impossible to decrypt it.
|
|
||||||
c.txDict = append(b, c.txDict...)
|
c.txDict = append(b, c.txDict...)
|
||||||
|
|
||||||
if len(c.txDict) > maxWindowBits {
|
if len(c.txDict) > maxWindowBits {
|
||||||
|
@ -1182,13 +1176,8 @@ func (c *Conn) AddTxDict(b []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddTxDict adds payload to rxDict.
|
||||||
func (c *Conn) AddRxDict(b []byte) {
|
func (c *Conn) AddRxDict(b []byte) {
|
||||||
c.mutex.Lock()
|
|
||||||
defer c.mutex.Unlock()
|
|
||||||
|
|
||||||
// Todo I do not know whether to leave the dictionary with 32768 bytes or more
|
|
||||||
// If it is recognized as a duplicate character string,
|
|
||||||
// deleting a part of the character may make it impossible to decrypt it.
|
|
||||||
c.rxDict = append(b, c.rxDict...)
|
c.rxDict = append(b, c.rxDict...)
|
||||||
|
|
||||||
if len(c.rxDict) > maxWindowBits {
|
if len(c.rxDict) > maxWindowBits {
|
||||||
|
|
Loading…
Reference in New Issue