mirror of https://github.com/gorilla/websocket.git
fix isWriting not needed, because conn.Write aleady do this.
This commit is contained in:
parent
a91eba7f97
commit
90d801b00c
19
conn.go
19
conn.go
|
@ -235,7 +235,6 @@ type Conn struct {
|
|||
writeBuf []byte // frame is constructed in this buffer.
|
||||
writeDeadline time.Time
|
||||
writer io.WriteCloser // the current writer returned to the application
|
||||
isWriting bool // for best-effort concurrent write detection
|
||||
|
||||
writeErrMu sync.Mutex
|
||||
writeErr error
|
||||
|
@ -581,18 +580,8 @@ func (w *messageWriter) flushFrame(final bool, extra []byte) error {
|
|||
// concurrent writes. See the concurrency section in the package
|
||||
// documentation for more info.
|
||||
|
||||
if c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = true
|
||||
|
||||
err := c.write(w.frameType, c.writeDeadline, c.writeBuf[framePos:w.pos], extra)
|
||||
|
||||
if !c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = false
|
||||
|
||||
if err != nil {
|
||||
return w.fatal(err)
|
||||
}
|
||||
|
@ -713,15 +702,7 @@ func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = true
|
||||
err = c.write(frameType, c.writeDeadline, frameData, nil)
|
||||
if !c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = false
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue