Fix pull-filters

Signed-off-by: Rahix <rahix@rahix.de>
This commit is contained in:
rahix 2019-04-16 01:52:17 +02:00
parent 888ad288af
commit 0eed392d6e

10
bc.lua
View file

@ -77,7 +77,7 @@ function Network:pull(filter, timeout)
last_msg = serialization.unserialize(msg)
return filter(addr_remote, last_msg)
end)
if ev ~= "nil" then
if ev ~= nil then
return last_msg
else
return nil, "timeout"
@ -189,6 +189,7 @@ function BaseControl:get(noun, timeout)
if remote ~= self.remote_nouns[noun] then return false end
if msg.ty ~= Message.NounResponse then return false end
if msg.noun ~= noun then return false end
return true
end, timeout)
if answer == nil then
return nil, err
@ -262,9 +263,10 @@ function BaseControl:call_sync(verb, ...)
sync=true,
})
local answer, err = self.network:pull(function(remote, msg)
if remote ~= self.remote_nouns[noun] then return false end
if msg.ty ~= Message.NounResponse then return false end
if msg.noun ~= noun then return false end
if remote ~= self.remote_verbs[verb] then return false end
if msg.ty ~= Message.VerbResponse then return false end
if msg.verb ~= verb then return false end
return true
end, timeout)
if answer ~= nil then
return table.unpack(answer.ret)