nimsuggest: fix tcp socket leak (#12377) [backport]

A new socket is created for each iteration and leak immediately thanks
to the accept() call replacing the created socket with the client socket.

This commit fixes that.

(cherry picked from commit e9fa4c9b9c)
This commit is contained in:
alaviss
2019-10-08 06:11:18 +00:00
committed by narimiran
parent 0a8dcd5e11
commit 4ae143ca60

View File

@@ -319,8 +319,8 @@ proc replTcp(x: ThreadParams) {.thread.} =
server.bindAddr(x.port, x.address)
server.listen()
var inp = "".TaintedString
var stdoutSocket: Socket
while true:
var stdoutSocket = newSocket()
accept(server, stdoutSocket)
stdoutSocket.readLine(inp)