Skip to content

Commit

Permalink
Be more flexible when detecting Windows:
Browse files Browse the repository at this point in the history
We need to know if we are using windows to decide which code to use to set
a socket to non-blocking behaviour in __fh_nonblocking (used by
__try_read_sock).

We had reports of blocking on Windows (see #20 and #21), and the
solution given on #21 is to use replace read() with sysread() in
__try_read_sock(). The fact that this works is a point in its favor,
but after that call, we do a ungetc() to put back what we've read.

According to Perl documentation, we should not mix sysread (unbuffered
I/O) with read/ungetc (buffered I/O) so I don't really like the sysread
solution.

So I'll try this first instead: the logic behind this commit is that for
some reason, the socket is not in non-blocking mode when it reaches the
read() call, and it blocks. This should catch more cases of mswin32 usage,
and it might fix the issue for good. If it does not, I'll quickly relase
a sysread-based release but that uses sysread only on Windows (I've tested
sysread on UNIX systems and it would break as expected).

Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information
melo committed Sep 4, 2012
1 parent 5905431 commit 59d32b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Redis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use Encode;
use Try::Tiny;
use Scalar::Util ();

use constant WIN32 => $^O eq 'MSWin32';
use constant WIN32 => $^O =~ /mswin32/i;


sub new {
Expand Down

0 comments on commit 59d32b1

Please sign in to comment.