aboutsummaryrefslogtreecommitdiff
path: root/src/linda.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 16:49:58 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-06-10 16:49:58 +0200
commitae582acdb1bfb3fb4171682b884545d174e95aa9 (patch)
treeb0c9c0b14f6d57cd8ce1c14d4d23df1adb0bc539 /src/linda.cpp
parent3f5c16116a3a7740ac4ac62b663661d772543c2e (diff)
downloadlanes-ae582acdb1bfb3fb4171682b884545d174e95aa9.tar.gz
lanes-ae582acdb1bfb3fb4171682b884545d174e95aa9.tar.bz2
lanes-ae582acdb1bfb3fb4171682b884545d174e95aa9.zip
linda:send() returns nil,<something> in case of error
Diffstat (limited to 'src/linda.cpp')
-rw-r--r--src/linda.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/linda.cpp b/src/linda.cpp
index 4dc2162..1bd5d16 100644
--- a/src/linda.cpp
+++ b/src/linda.cpp
@@ -709,17 +709,25 @@ LUAG_FUNC(linda_send)
709 709
710 switch (_cancel) { 710 switch (_cancel) {
711 case CancelRequest::Soft: 711 case CancelRequest::Soft:
712 // if user wants to soft-cancel, the call returns lanes.cancel_error 712 // if user wants to soft-cancel, the call returns nil, kCancelError
713 lua_pushnil(L_);
713 kCancelError.pushKey(L_); 714 kCancelError.pushKey(L_);
714 return 1; 715 return 2;
715 716
716 case CancelRequest::Hard: 717 case CancelRequest::Hard:
717 // raise an error interrupting execution only in case of hard cancel 718 // raise an error interrupting execution only in case of hard cancel
718 raise_cancel_error(L_); // raises an error and doesn't return 719 raise_cancel_error(L_); // raises an error and doesn't return
719 720
720 default: 721 default:
721 lua_pushboolean(L_, _ret); // true (success) or false (timeout) 722 if (_ret) {
722 return 1; 723 lua_pushboolean(L_, _ret); // true (success)
724 return 1;
725 } else {
726 // not enough room in the Linda slot to fulfill the request, return nil, "timeout"
727 lua_pushnil(L_);
728 std::ignore = luaG_pushstring(L_, "timeout");
729 return 2;
730 }
723 } 731 }
724 }; 732 };
725 return Linda::ProtectedCall(L_, _send); 733 return Linda::ProtectedCall(L_, _send);