diff options
author | Yves Orton <demerphq@gmail.com> | 2007-06-18 20:43:17 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-06-19 20:38:36 +0000 |
commit | 757754a6231584cc746ffd4510e6d8b8f2691824 (patch) | |
tree | f5d91a6d4845109cd145f68eb661bb6a1cb6ab2c /ext | |
parent | b7254abcd458ced5f5357ad0fd808fa82e099c55 (diff) | |
download | perl-757754a6231584cc746ffd4510e6d8b8f2691824.tar.gz |
Re: Net::SMTP can't send large messages with bleadperl
Message-ID: <9b18b3110706180943y22c0eaa7yf34565d87689dd9e@mail.gmail.com>
Date: Mon, 18 Jun 2007 18:43:17 +0200
p4raw-id: //depot/perl@31423
Diffstat (limited to 'ext')
-rw-r--r-- | ext/IO/lib/IO/Socket.pm | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/ext/IO/lib/IO/Socket.pm b/ext/IO/lib/IO/Socket.pm index 909509311b..f1fcddedaf 100644 --- a/ext/IO/lib/IO/Socket.pm +++ b/ext/IO/lib/IO/Socket.pm @@ -145,6 +145,11 @@ sub connect { $err ? undef : $sock; } +# Enable/disable blocking IO on sockets. +# Without args return the current status of blocking, +# with args change the mode as appropriate, returning the +# old setting, or in case of error during the mode change +# undef. sub blocking { my $sock = shift; @@ -154,22 +159,32 @@ sub blocking { # Windows handles blocking differently # - # http://groups.google.co.uk/group/perl.perl5.porters/browse_thread/ - # thread/b4e2b1d88280ddff/630b667a66e3509f?#630b667a66e3509f - # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ - # winsock/winsock/ioctlsocket_2.asp + # http://groups.google.co.uk/group/perl.perl5.porters/browse_thread/thread/b4e2b1d88280ddff/630b667a66e3509f?#630b667a66e3509f + # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/ioctlsocket_2.asp # # 0x8004667e is FIONBIO - # By default all sockets are blocking - - return !${*$sock}{io_sock_nonblocking} - unless @_; + # + # which is used to set blocking behaviour. - my $block = shift; + # NOTE: + # This is a little confusing, the perl keyword for this is + # 'blocking' but the OS level behaviour is 'non-blocking', probably + # because sockets are blocking by default. + # Therefore internally we have to reverse the semantics. - ${*$sock}{io_sock_nonblocking} = $block ? "0" : "1"; + my $orig= !${*$sock}{io_sock_nonblocking}; + + return $orig unless @_; - return ioctl($sock, 0x8004667e, \${*$sock}{io_sock_nonblocking}); + my $block = shift; + + if ( !$block != !$orig ) { + ${*$sock}{io_sock_nonblocking} = $block ? 0 : 1; + ioctl($sock, 0x8004667e, pack("L!",${*$sock}{io_sock_nonblocking})) + or return undef; + } + + return $orig; } |