Permalink
Browse files

Be more flexible when detecting Windows:

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...
1 parent 5905431 commit 59d32b1f64427d70c07db5323a5f61504b2d9d8a @melo melo committed Sep 4, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/Redis.pm
View
@@ -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 {

0 comments on commit 59d32b1

Please sign in to comment.