From 513659a6facfc17bc7191c79c4e78d178a076605 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Sat, 14 May 2011 11:14:15 +0200 Subject: linda:send() raises an error when there is no data to send instead of silently doing nothing. --- CHANGES | 3 +++ src/keeper.lua | 1 - src/lanes.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index f4ff88a..f7ab99f 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,9 @@ CHANGES: CHANGE X: +CHANGE 32 BGe 14-May-2011 +* raise an error when linda:send() has nothing to send + CHANGE 31 BGe 17-Apr-2011 * linda uses a fast FIFO implementation to speed up data exchanges * new linda:count() method diff --git a/src/keeper.lua b/src/keeper.lua index 828932e..77bf880 100644 --- a/src/keeper.lua +++ b/src/keeper.lua @@ -150,7 +150,6 @@ function send( ud, key, ...) local data, limits = tables( ud) local n = select( '#', ...) - if n == 0 then return true end -- nothing to send -- Initialize queue for all keys that have been used with ':send()' -- diff --git a/src/lanes.c b/src/lanes.c index e514e6b..ed54b0f 100644 --- a/src/lanes.c +++ b/src/lanes.c @@ -295,6 +295,12 @@ LUAG_FUNC( linda_send) // make sure the keys are of a valid type check_key_types( L, key_i, key_i); + // make sure there is something to send + if( lua_gettop( L) == key_i) + { + luaL_error( L, "no data to send"); + } + // convert nils to some special non-nil sentinel in sent values keeper_toggle_nil_sentinels( L, key_i + 1, 1); -- cgit v1.2.3-55-g6feb