fix non-blocking so that it actually doesn't block!
authorminima <minima>
Fri, 30 Mar 2001 14:46:29 +0000 (14:46 +0000)
committerminima <minima>
Fri, 30 Mar 2001 14:46:29 +0000 (14:46 +0000)
Changes
perl/ExtMsg.pm
perl/Msg.pm

diff --git a/Changes b/Changes
index 85abff6e6c33c325bec0cabe19dada38af704f9f..166b28ea58d6a8bb5d68d2156bcc11b9aa2b4adc 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,6 @@
 30Mar01=======================================================================
 1. fix errors on accept in ExtMsg and in Msg
+2. fix the non-blocking problems of connects (and other things in general).
 29Mar01=======================================================================
 1. add better tracking of AGW circuits (possibly)
 2. add set and unset/agwmonitor (ing) [for all the notice it seems to take]
index be21d9583cf37682b7b21ab6758e019bf11319c8..ae6c8a4c447a8d6bd5d56b528634589593f49b1b 100644 (file)
@@ -126,6 +126,8 @@ sub new_client {
        if ($sock) {
                my $conn = $server_conn->new($server_conn->{rproc});
                $conn->{sock} = $sock;
+               Msg::blocking($sock, 0);
+               $conn->{blocking} = 0;
                
                my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
                if ($eproc) {
index 1ed5377c20f890238aba810e798f4c54ec5bfeef..aa5edc48bd4a8ba454005f3ff8c3e5df5f8fc7cf 100644 (file)
@@ -16,7 +16,7 @@ use IO::Socket;
 use DXDebug;
 use Timer;
 
-use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns);
+use vars qw(%rd_callbacks %wt_callbacks %er_callbacks $rd_handles $wt_handles $er_handles $now %conns $noconns $blocking_supported);
 
 %rd_callbacks = ();
 %wt_callbacks = ();
@@ -26,14 +26,19 @@ $wt_handles   = IO::Select->new();
 $er_handles   = IO::Select->new();
 
 $now = time;
-my $blocking_supported = 0;
 
 BEGIN {
     # Checks if blocking is supported
     eval {
-        require POSIX; POSIX->import(qw (F_SETFL F_GETFL O_NONBLOCK));
+        require POSIX; POSIX->import(qw(O_NONBLOCK F_SETFL F_GETFL))
     };
-    $blocking_supported = 1 unless $@;
+       if ($@) {
+               print STDERR "POSIX Blocking *** NOT *** supported $@\n";
+       } else {
+               $blocking_supported = 1;
+               print STDERR "POSIX Blocking enabled\n";
+       }
+
 
        # import as many of these errno values as are available
        eval {
@@ -155,10 +160,8 @@ sub connect {
        my $proto = getprotobyname('tcp');
        $sock->socket(AF_INET, SOCK_STREAM, $proto) or return undef;
        
-       if ($conn->{blocking}) {
-               blocking($sock, 0);
-               $conn->{blocking} = 0;
-       }
+       blocking($sock, 0);
+       $conn->{blocking} = 0;
 
        my $ip = gethostbyname($to_host);
 #      my $r = $sock->connect($to_port, $ip);
@@ -394,6 +397,8 @@ sub new_client {
        if ($sock) {
                my $conn = $server_conn->new($server_conn->{rproc});
                $conn->{sock} = $sock;
+               blocking($sock, 0);
+               $conn->{blocking} = 0;
                my ($rproc, $eproc) = &{$server_conn->{rproc}} ($conn, $conn->{peerhost} = $sock->peerhost(), $conn->{peerport} = $sock->peerport());
                $conn->{sort} = 'Incoming';
                if ($eproc) {