From: minima Date: Wed, 14 Mar 2001 17:00:06 +0000 (+0000) Subject: change interface to connect X-Git-Tag: R_1_47~117 X-Git-Url: http://dxspider.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=2bbb601161d60a41289bd19b73fc35c24d5c6b71;p=spider.git change interface to connect --- diff --git a/Changes b/Changes index 5d94c2c9..ace7ca29 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ 14Mar01======================================================================= 1. first cut at outgoing ax25 /external program connects +2. slight change of interface to connect 13Mar01======================================================================= 1. implemented first cut at non blocking connect 2. removed memory leakage in connects diff --git a/perl/ExtMsg.pm b/perl/ExtMsg.pm index 954703b3..b39637d1 100644 --- a/perl/ExtMsg.pm +++ b/perl/ExtMsg.pm @@ -19,6 +19,7 @@ use DXUtil; use DXDebug; use IO::File; use IO::Socket; +use IPC::Open2; use vars qw(@ISA $deftimeout); @@ -210,29 +211,19 @@ sub _doconnect dbg('connect', "***Connect Failed to $host $port $!"); } } elsif ($sort eq 'ax25' || $sort eq 'prog') { - my $pid = fork(); - if (defined $pid) { - if (!$pid) { - # in child, unset warnings, disable debugging and general clean up from us - $^W = 0; - eval "{ package DB; sub DB {} }"; - DXChannel::closeall(); - for (@main::listeners) { - $_->close_server; - } - unless ($^O =~ /^MS/) { - $SIG{HUP} = 'IGNORE'; - $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT'; - alarm(0); - } - exec "$line" or dbg('cron', "exec '$line' failed $!"); + $conn->{sock} = new IO::File; + if ($conn->{sock}) { + my $outfd = fileno($conn->{sock}); + my $out = new IO::File ">&$outfd"; + if ($conn->{pid} = open2($conn->{sock}, $out, $line)) { + $conn->{csort} = $sort; + $conn->{lineend} = "\cM" if $sort eq 'ax25'; + dbg('connect', "started $line"); + } else { + dbg('connect', "can't start $line $!"); } - dbg('connect', "program $sort $line started"); - $conn->{pid} = $pid; - $conn->{csort} = $sort; - $conn->{lineend} = "\cM" if $sort eq 'ax25'; } else { - dbg('connect', "can't $sort fork for $line $!"); + dbg('connect', "can't start $line $!"); } } else { dbg('err', "invalid type of connection ($sort)"); diff --git a/perl/Msg.pm b/perl/Msg.pm index eb6892a8..839b5e45 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -135,7 +135,8 @@ sub connect { blocking($sock, 0); my $ip = gethostbyname($to_host); - my $r = $sock->connect($to_port, $ip); +# my $r = $sock->connect($to_port, $ip); + my $r = connect($sock, pack_sockaddr_in($to_port, $ip)); unless ($r) { return undef unless $! == EINPROGRESS; }