make sure the lock is init before cleanUpResources

This commit is contained in:
Ivan FB 2026-04-24 14:22:34 +02:00
parent 73221eb1d4
commit f9f2025b98
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270

View File

@ -197,13 +197,16 @@ proc createFFIContext*[T](): Result[ptr FFIContext[T], string] =
## This proc is called from the main thread and it creates
## the FFI working thread.
var ctx = createShared(FFIContext[T], 1)
ctx.lock.initLock()
ctx.reqSignal = ThreadSignalPtr.new().valueOr:
ctx.cleanUpResources()
return err("couldn't create reqSignal ThreadSignalPtr")
ctx.reqReceivedSignal = ThreadSignalPtr.new().valueOr:
ctx.cleanUpResources()
return err("couldn't create reqReceivedSignal ThreadSignalPtr")
ctx.lock.initLock()
ctx.registeredRequests = addr ffi_types.registeredRequests
ctx.running.store(true)