Переглянути джерело

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
 	}

Завантаження…
Відмінити
Зберегти