瀏覽代碼

fix a race condition

Setting `closed` on the socket (which can mean either "the socket is broken"
or "we should close the socket at the next opportunity") was racing against
the final write. Even if socket.closed is true, we should attempt to send
buffered message data to the socket, before we send the `finalData` and
actually call `Close`.
tags/v1.1.0-rc1
Shivaram Lingamneni 5 年之前
父節點
當前提交
0af0a0b445
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1
    1
      irc/socket.go

+ 1
- 1
irc/socket.go 查看文件

@@ -254,7 +254,7 @@ func (socket *Socket) performWrite() (closed bool) {
254 254
 	socket.Unlock()
255 255
 
256 256
 	var err error
257
-	if !closed && len(buffers) > 0 {
257
+	if 0 < len(buffers) {
258 258
 		// on Linux, the runtime will optimize this into a single writev(2) call:
259 259
 		_, err = (*net.Buffers)(&buffers).WriteTo(socket.conn)
260 260
 	}

Loading…
取消
儲存