X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FMsg.pm;h=5ac71b428e44d793bc74f49e1dfb569bc4f04311;hb=686140dd3cb3c832d8bb6c780acd82effb54834c;hp=c3637fb0bf6843320e97bf0c658e19345007c073;hpb=e8fe72d833414c4bb7f017ed0b62167aa5ac593d;p=spider.git diff --git a/perl/Msg.pm b/perl/Msg.pm index c3637fb0..5ac71b42 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -12,11 +12,10 @@ package Msg; use strict; +use DXUtil; + use vars qw($VERSION $BRANCH); -$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); -$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0)); -$main::build += $VERSION; -$main::branch += $BRANCH; +($VERSION, $BRANCH) = dxver(q$Revision$); use IO::Select; use IO::Socket; @@ -42,11 +41,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 +136,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]) { @@ -217,7 +210,6 @@ sub connect { my $ip = gethostbyname($to_host); return undef unless $ip; -# my $r = $sock->connect($to_port, $ip); my $r = connect($sock, pack_sockaddr_in($to_port, $ip)); return undef unless $r || _err_will_block($!); @@ -347,10 +339,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) {