fix isWriting not needed, because conn.Write aleady do this.

This commit is contained in:
hetao 2017-06-13 12:09:55 +08:00
parent a91eba7f97
commit 90d801b00c
1 changed files with 0 additions and 19 deletions

19
conn.go
View File

@ -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
}