From 17f98b33ed26338094a08d25e9fbf25b71c58f16 Mon Sep 17 00:00:00 2001
From: Benoit Germain <benoit.germain@ubisoft.com>
Date: Tue, 11 Jun 2024 10:02:12 +0200
Subject: Fix lanes.genlock()

---
 src/lanes.lua | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/lanes.lua b/src/lanes.lua
index 1378412..07792b6 100644
--- a/src/lanes.lua
+++ b/src/lanes.lua
@@ -685,7 +685,11 @@ local genlock = function(linda_, key_, N)
         local timeout = (mode_ == "try") and 0 or nil
         if M_ > 0 then
             -- 'nil' timeout allows 'key_' to be numeric
-            return linda_:send(timeout, key_, true)    -- suspends until been able to push them
+            local _status, _err = linda_:send(timeout, key_, true) -- suspends until been able to push them
+            -- if success, _status is true, that's what we return
+            -- if failure, _status is nil, _err contains the error, that's what we return
+            -- propagate cancel_error if we got it, else return true or false
+            return (_err == cancel_error and _err) or (_status and true or false)
         else
             local _k, _v = linda_:receive(nil, key_)
             -- propagate cancel_error if we got it, else return true or false
-- 
cgit v1.2.3-55-g6feb