From 51904800e252cf4c286f1cb740ae58abdb56cb9a Mon Sep 17 00:00:00 2001 From: minima Date: Sun, 7 Jan 2007 23:04:33 +0000 Subject: [PATCH] use IO::Socket blocking wherever possible --- Changes | 3 +++ perl/Msg.pm | 22 ++++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Changes b/Changes index d21ef03d..10d33696 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +07Jan06======================================================================= +1. use IO::Socket blocking where available and switch off or ignore all +attempts to block. 05Jan06======================================================================= 1. increase default ephemeral deduping on PC15 to 6 minutes (from 2). 23Nov06======================================================================= diff --git a/perl/Msg.pm b/perl/Msg.pm index 00569928..e13be8f3 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -42,11 +42,9 @@ BEGIN { require POSIX; POSIX->import(qw(O_NONBLOCK F_SETFL F_GETFL)) }; if ($@ || $main::is_win) { -# print STDERR "POSIX Blocking *** NOT *** supported $@\n"; - $blocking_supported = 0; + $blocking_supported = IO::Socket->can('blocking') ? 2 : 0; } else { - $blocking_supported = 1; -# print STDERR "POSIX Blocking enabled\n"; + $blocking_supported = IO::Socket->can('blocking') ? 2 : 1; } @@ -139,12 +137,8 @@ sub blocking return unless $blocking_supported; # Make the handle stop blocking, the Windows way. - if ($main::is_win) { - # 126 is FIONBIO (some docs say 0x7F << 16) - ioctl( $_[0], - 0x80000000 | (4 << 16) | (ord('f') << 8) | 126, - "$_[1]" - ); + if ($blocking_supported) { + $_[0]->blocking($_[1]); } else { my $flags = fcntl ($_[0], F_GETFL, 0); if ($_[1]) { @@ -346,10 +340,10 @@ sub _send { # return to the event loop only after every message, or if it # is likely to block in the middle of a message. - if ($conn->{blocking} != $flush) { - blocking($sock, $flush); - $conn->{blocking} = $flush; - } +# if ($conn->{blocking} != $flush) { +# blocking($sock, $flush); +# $conn->{blocking} = $flush; +# } my $offset = (exists $conn->{send_offset}) ? $conn->{send_offset} : 0; while (@$rq) { -- 2.34.1