Ivan FB 431f2afe7b
fix(libsds): adapt to nim-ffi 0.1.5 recycle API
nim-ffi 0.1.5 reworked the context pool to recycle contexts (reuse the
worker thread + its fds) instead of tearing them down per cycle, which is
what fixes the per-create/destroy fd leak. Two consumer-side changes are
required for libsds to work with it:

- SdsCreateRmReq: nim-ffi no longer points `myLib` at a thread-stack var;
  it owns it as a createShared'd object and frees it on recycle. So the
  handler must (re)allocate `ctx.myLib` before assigning, otherwise the
  first create dereferences a nil `myLib` and segfaults.

- SdsCleanupReliabilityManager: use `releaseFFIContext` (recycle) instead
  of `destroyFFIContext` (full teardown). Recycle keeps the worker and its
  fds alive for the next manager; destroy would reintroduce the leak. It is
  non-blocking and fires `callback` from the FFI thread once drained, so the
  synchronous RET_OK fire is dropped.

Lock nim-ffi to 0.1.5 (f6a3a33). Verified: libsds builds (--mm:refc) and the
status-go reliability suite (incl. the multi-manager fd test) is green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 18:46:15 +02:00
..