Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Redis CPAN distribution.

Report information
The Basics
Id: 64040
Status: resolved
Priority: 0/
Queue: Redis

People
Owner: melo [...] cpan.org
Requestors: DKU [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.2001
Fixed in: (no value)



Subject: BLPOP that times out doesn't properly return
If I do $redis->blpop( 'somekey', 2 ), and the timeout expires (nil is returned through the socket), the module erroneously tries to continue reading from the socket, when there is nothing left to read. As a result, blpop hangs indefinitely.
On Sat Dec 18 15:15:48 2010, DKU wrote: Show quoted text
> If I do $redis->blpop( 'somekey', 2 ), and the timeout expires (nil is > returned through the socket), the module erroneously tries to continue > reading from the socket, when there is nothing left to read. As a
result, Show quoted text
> blpop hangs indefinitely.
This is easily fixable by adding a 'return if $result < 0;' immediately following the 'elsif ($type eq '*') {' in __read_response.
Hi, I believe this is fixed in 1.901. If the server closes the connection for some reason, the read(2) on our side will fail and an exception will be thrown. Could you please check? Thanks,
This remains broken in 1.903. I'd like to point to my earlier comments for an explanation on why. Per the Redis API, if a BLPOP is ran, and the timeout provided by the BLPOP command is exceeded, Redis will return a NIL multi-bulk reply. Here's how a non-NIL multi-bulk reply looks like (which Redis.pm handles fine): $ telnet localhost 6379 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. rpush key 2 :1 blpop key 2 *2 $4 key $1 2 Here's how a NIL multi-bulk looks like (which isn't handled properly): $ telnet localhost 6379 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. blpop randomkey 2 *-1 (That response is explained in the multi-bulk section of the Redis protocol spec: http://redis.io/topics/protocol). Redis.pm reads the * and interprets it as a multi-bulk reply (line 374 in 1.903). You store the -1 into $result. Following that, your code reads: "while($result--) {...". Since $result contains -1, the while() never terminates and the code perpetually hangs. Like I said above, this is easily remedied by changing the code around line 374 to read: elsif($type eq '*') { return if $result < 0; # <---- will now handle *-1 properly my @list; # ...
On Sat Mar 05 16:22:56 2011, DKU wrote: Show quoted text
> This remains broken in 1.903. I'd like to point to my earlier comments > for an explanation on why. Per the Redis API, if a BLPOP is ran, and the > timeout provided by the BLPOP command is exceeded, Redis will return a > NIL multi-bulk reply. Here's how a non-NIL multi-bulk reply looks like > (which Redis.pm handles fine):
Ah yes, I understand it now. Will fix tonight, expect a release in a hour or so. Thanks,
Fixed in 1.904. Thanks,