Ver código fonte

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 anos atrás
pai
commit
0af0a0b445
1 arquivos alterados com 1 adições e 1 exclusões
  1. 1
    1
      irc/socket.go

+ 1
- 1
irc/socket.go Ver arquivo

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

Carregando…
Cancelar
Salvar