Commit 1344445e authored by Hchen's avatar Hchen
Browse files

fix: Write panic when conn Close (#96)

parent 985eb363
Showing with 7 additions and 1 deletion
+7 -1
......@@ -242,9 +242,15 @@ func (c *connection) Read(p []byte) (n int, err error) {
// Write will Flush soon.
func (c *connection) Write(p []byte) (n int, err error) {
if !c.lock(flushing) {
return 0, Exception(ErrConnClosed, "when write")
}
defer c.unlock(flushing)
dst, _ := c.outputBuffer.Malloc(len(p))
n = copy(dst, p)
err = c.Flush()
c.outputBuffer.Flush()
err = c.flush()
return n, err
}
......
Supports Markdown
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