diff options
author | Stephen Oberholtzer <oliverklozoff@gmail.com> | 2011-08-16 09:35:54 -0400 |
---|---|---|
committer | Steve Hay <steve.m.hay@googlemail.com> | 2011-08-16 17:11:42 +0100 |
commit | f5458e3a4f5fed75a7fe0b26182af4c52e76a186 (patch) | |
tree | 98f5fe5c50bcb79067e0c780c99ecad9387ee46d /dist | |
parent | 107813b01928a8dad7ac6980549e277a9d99f8cd (diff) | |
download | perl-f5458e3a4f5fed75a7fe0b26182af4c52e76a186.tar.gz |
Fix setting sockets nonblocking in Win32
Diffstat (limited to 'dist')
-rw-r--r-- | dist/IO/IO.xs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/dist/IO/IO.xs b/dist/IO/IO.xs index e8e9e556e8..dfbe3bd262 100644 --- a/dist/IO/IO.xs +++ b/dist/IO/IO.xs @@ -122,8 +122,20 @@ io_blocking(pTHX_ InputStream f, int block) return RETVAL; #else # ifdef WIN32 - char flags = (char)block; - return ioctl(PerlIO_fileno(f), FIONBIO, &flags); + if (block >= 0) { + unsigned long flags = !block; + /* ioctl claims to take char* but really needs a u_long sized buffer */ + const int ret = ioctl(PerlIO_fileno(f), FIONBIO, (char*)&flags); + if (ret != 0) + return -1; + /* Win32 has no way to get the current blocking status of a socket. + * However, we don't want to just return undef, because there's no way + * to tell that the ioctl succeeded. + */ + return flags; + } + /* TODO: Perhaps set $! to ENOTSUP? */ + return -1; # else return -1; # endif |