userSock may be closed in handleRequest, so check before recvLine

This commit is contained in:
Christian Ulrich 2020-07-27 23:51:16 +02:00
parent 7c010f9303
commit 5d08473d86
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 2 additions and 0 deletions

View File

@ -64,6 +64,8 @@ proc handleRequest(line: string, unixSock: AsyncSocket) {.async.} =
proc handleRequests(userSock: AsyncSocket) {.async.} =
while true:
if userSock.isClosed:
break
let line = await userSock.recvLine(maxLength = 400)
if line.len == 0:
break