fix crash issue on read after close

master
fangdingjun 6 years ago
parent c5d91a0951
commit 3c2bd315dc

@ -204,7 +204,9 @@ func (c *Conn) Read(buf []byte) (n int, err error) {
if len(buf) == 0 { if len(buf) == 0 {
return 0, nil return 0, nil
} }
if c.closed {
return 0, io.EOF
}
//bufLen := len(buf) //bufLen := len(buf)
//cbuf := C.malloc(C.size_t(bufLen)) //cbuf := C.malloc(C.size_t(bufLen))
//defer C.free(cbuf) //defer C.free(cbuf)
@ -237,7 +239,9 @@ func (c *Conn) Write(buf []byte) (n int, err error) {
if len(buf) == 0 { if len(buf) == 0 {
return 0, nil return 0, nil
} }
if c.closed {
return 0, io.EOF
}
//cbuf := C.CBytes(buf) //cbuf := C.CBytes(buf)
//defer C.free(cbuf) //defer C.free(cbuf)

Loading…
Cancel
Save