From f9f2025b9841f5b87f62b46730b560e194fb0beb Mon Sep 17 00:00:00 2001 From: Ivan FB Date: Fri, 24 Apr 2026 14:22:34 +0200 Subject: [PATCH] make sure the lock is init before cleanUpResources --- ffi/ffi_context.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ffi/ffi_context.nim b/ffi/ffi_context.nim index f53a662..7bb4ae2 100644 --- a/ffi/ffi_context.nim +++ b/ffi/ffi_context.nim @@ -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)