lib/pigato/client.rb in pigato-0.4.5 vs lib/pigato/client.rb in pigato-0.4.6
- old
+ new
@@ -40,14 +40,16 @@
request.reverse.each{|p| msg.push(ZMQ::Frame(p))}
res = send msg
return nil if res.nil?
+ rtimer = Time.now + (@conf[:timeout] * 0.001)
+
res = []
- while 1 do
+ while Time.now <= rtimer do
chunk = _recv rid
- break if chunk == nil
+ next if chunk == nil
res << Oj.load(chunk[4])
break if chunk[0] == Pigato::W_REPLY
end
return nil if res.length == 0
@@ -56,11 +58,11 @@
end
def _recv rid
iid = get_iid
socket = @@sockets[iid]
- socket.rcvtimeo = @conf[:timeout]
+ socket.rcvtimeo = 2500
data = []
msg = socket.recv_message()
while 1 do
@@ -68,11 +70,11 @@
data << msg.pop.data
end
if data[3] != rid
data = []
- if conf[:logger]
- conf[:logger].error("PigatoClient: RID mismatch")
+ if @conf[:logger]
+ @conf[:logger].error("PigatoClient: RID mismatch #{data[3]}/#{rid}")
end
end
return nil if data.length == 0