Investigation of Linux freezes #3.

This commit is contained in:
cheatfate 2021-01-20 22:40:23 +02:00 committed by zah
parent cf42a5455e
commit f1b43aeb04
1 changed files with 5 additions and 3 deletions

View File

@ -274,12 +274,15 @@ proc failPendingWriteQueue(queue: var Deque[StreamVector],
vector.writer.fail(error)
proc clean(server: StreamServer) {.inline.} =
echo "cleaning server instance"
if not(server.loopFuture.finished()):
echo "cleaning server complete()"
untrackServer(server)
server.loopFuture.complete()
if not isNil(server.udata) and GCUserData in server.flags:
GC_unref(cast[ref int](server.udata))
GC_unref(server)
echo "clean server exit"
proc clean(transp: StreamTransport) {.inline.} =
if not(transp.future.finished()):
@ -1639,9 +1642,8 @@ proc close*(server: StreamServer) =
## Please note that release of resources is not completed immediately, to be
## sure all resources got released please use ``await server.join()``.
proc continuation(udata: pointer) {.gcsafe.} =
# Stop tracking server
if not(server.loopFuture.finished()):
server.clean()
echo "server close() continuation"
server.clean()
let r1 = (server.status == ServerStatus.Stopped) and
not(isNil(server.function))