avoid segfault on fullcollect

This commit is contained in:
Dmitriy Ryajov 2023-09-20 17:29:25 -06:00
parent 9013a0c619
commit 215d334400
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4

View File

@ -140,9 +140,6 @@ suite "Test ThreadDatastore cancelations":
sqlStore: Datastore sqlStore: Datastore
ds: ThreadDatastore ds: ThreadDatastore
taskPool: Taskpool taskPool: Taskpool
key = Key.init("/a/b").tryGet()
bytes = "some bytes".toBytes
otherBytes = "some other bytes".toBytes
privateAccess(ThreadDatastore) # expose private fields privateAccess(ThreadDatastore) # expose private fields
privateAccess(TaskCtx) # expose private fields privateAccess(TaskCtx) # expose private fields
@ -153,7 +150,7 @@ suite "Test ThreadDatastore cancelations":
ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet() ds = ThreadDatastore.new(sqlStore, tp = taskPool).tryGet()
teardown: teardown:
GC_fullCollect() GC_fullCollect() # run full collect after each test
teardownAll: teardownAll:
(await ds.close()).tryGet() (await ds.close()).tryGet()
@ -169,8 +166,6 @@ suite "Test ThreadDatastore cancelations":
signal: signal) signal: signal)
fut = newFuture[void]("signalMonitor") fut = newFuture[void]("signalMonitor")
threadArgs = (addr ctx, addr fut) threadArgs = (addr ctx, addr fut)
var
thread: Thread[type threadArgs] thread: Thread[type threadArgs]
proc threadTask(args: type threadArgs) = proc threadTask(args: type threadArgs) =
@ -191,6 +186,7 @@ suite "Test ThreadDatastore cancelations":
check: fut.cancelled check: fut.cancelled
check: ctx.signal.close().isOk check: ctx.signal.close().isOk
fut = nil
test "Should monitor and not cancel": test "Should monitor and not cancel":
var var
@ -202,8 +198,6 @@ suite "Test ThreadDatastore cancelations":
signal: signal) signal: signal)
fut = newFuture[void]("signalMonitor") fut = newFuture[void]("signalMonitor")
threadArgs = (addr ctx, addr fut) threadArgs = (addr ctx, addr fut)
var
thread: Thread[type threadArgs] thread: Thread[type threadArgs]
proc threadTask(args: type threadArgs) = proc threadTask(args: type threadArgs) =
@ -224,3 +218,4 @@ suite "Test ThreadDatastore cancelations":
check: not fut.cancelled check: not fut.cancelled
check: ctx.signal.close().isOk check: ctx.signal.close().isOk
fut = nil