rx and coresimurx terminate when all connections to target system terminate
git-svn-id: http://repo.ham.fi/svn/aprsc/trunk@261 3ce903b1-3385-4e86-93cd-f9a4a239f7ac
This commit is contained in:
parent
038d1fd51a
commit
6d1a254203
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
$VERSION = 'APRS-IS-CORESIMRX version-1.0';
|
||||
|
||||
use strict;
|
||||
use POSIX;
|
||||
use IO::Multiplex;
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ select STDOUT; $| = 1;
|
|||
my $quit = 0;
|
||||
my $APRSIS;
|
||||
my $N = 10;
|
||||
my $fdcount = 0;
|
||||
|
||||
my @specdata = simspecs();
|
||||
# printf "specdata: $#specdata\n";
|
||||
|
|
@ -30,7 +32,7 @@ my @specdata = simspecs();
|
|||
## Now fork me N ways..
|
||||
|
||||
if ($N > 1) {
|
||||
for $n (1..$N) {
|
||||
foreach my $n (1..$N) {
|
||||
my $pid = fork();
|
||||
if ($pid == 0) { # Client
|
||||
work($n % $N,$N);
|
||||
|
|
@ -38,7 +40,7 @@ if ($N > 1) {
|
|||
}
|
||||
}
|
||||
|
||||
for $n (1..$N) {
|
||||
foreach my $n (1..$N) {
|
||||
wait;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -53,8 +55,10 @@ sub work {
|
|||
my @APRS = ();
|
||||
my $MUX = new IO::Multiplex;
|
||||
my $u;
|
||||
|
||||
my $n = 0;
|
||||
|
||||
$fdcount = 0;
|
||||
|
||||
foreach my $l (@specdata) {
|
||||
|
||||
++$n;
|
||||
|
|
@ -86,9 +90,12 @@ sub work {
|
|||
}
|
||||
|
||||
$MUX->add( $APRSIS->sock() );
|
||||
++$fdcount;
|
||||
|
||||
$u = $APRSIS->socku();
|
||||
$MUX->add( $u ) if (defined($u));
|
||||
if (defined($u)) {
|
||||
$MUX->add( $u );
|
||||
}
|
||||
|
||||
push @APRS, $APRSIS;
|
||||
}
|
||||
|
|
@ -122,10 +129,17 @@ sub mux_input {
|
|||
|
||||
sub mux_eof {
|
||||
my $package = shift;
|
||||
my $mux = shift;
|
||||
my $MUX = shift;
|
||||
my $fh = shift;
|
||||
|
||||
$MUX->shutdown($fh, 1);
|
||||
$MUX->close($fh);
|
||||
$MUX->remove($fh);
|
||||
|
||||
--$fdcount; ## count controls only..
|
||||
if ($fdcount == 0) {
|
||||
$MUX->endloop();
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,14 @@ my $mycall = 'OH2MQK-RR';
|
|||
#$filter = 'p/OH';
|
||||
|
||||
#$APRSIS = APRS::IS->new('finland.aprs2.net:10152', $mycall, $filter);
|
||||
#$APRSIS = APRS::IS->new('finland.aprs2.net:10152u', $mycall, $filter);
|
||||
#$APRSIS = APRS::IS->new('finland.aprs2.net:14580u', $mycall, $filter);
|
||||
#$APRSIS = APRS::IS->new('rotate.aprs.net:23', $mycall, $filter);
|
||||
$APRSIS = APRS::IS->new('first.aprs.net:10152u', $mycall, $filter );
|
||||
#$APRSIS = APRS::IS->new('first.aprs.net:24579', $mycall, undef );
|
||||
#$APRSIS = APRS::IS->new('localhost:10152u', $mycall, $filter );
|
||||
#$APRSIS = APRS::IS->new('localhost:14580', $mycall, $filter );
|
||||
#$APRSIS = APRS::IS->new('localhost:14580u', $mycall, $filter );
|
||||
|
||||
if (!defined($APRSIS)) {
|
||||
printf "aprsazel: Failed to open APRS-IS socket!\n";
|
||||
|
|
@ -43,29 +47,40 @@ exit 0;
|
|||
|
||||
sub mux_input {
|
||||
my $package = shift;
|
||||
my $mux = shift;
|
||||
my $MUX = shift;
|
||||
my $fh = shift;
|
||||
my $data = shift;
|
||||
|
||||
if (fileno($fh) == fileno($Uclient)) {
|
||||
if ($MUX->is_udp($fh)) {
|
||||
printf "%d\t%s\n", time, $$data;
|
||||
$$data = '';
|
||||
|
||||
} else {
|
||||
|
||||
# Process each line in the input, leaving partial lines
|
||||
# in the input buffer
|
||||
while ($$data =~ s/^(.*?)\n//) {
|
||||
printf "%d\t%s\n", time, $1;
|
||||
}
|
||||
}
|
||||
|
||||
# Process each line in the input, leaving partial lines
|
||||
# in the input buffer
|
||||
while ($$data =~ s/^(.*?)\n//) {
|
||||
printf "%d\t%s\n", time, $1;
|
||||
if (time > $last) {
|
||||
$MUX->close($fh);
|
||||
$MUX->remove($fh);
|
||||
$MUX->endloop();
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub mux_eof {
|
||||
my $package = shift;
|
||||
my $mux = shift;
|
||||
my $MUX = shift;
|
||||
my $fh = shift;
|
||||
|
||||
$MUX->close($fh);
|
||||
$MUX->remove($fh);
|
||||
$MUX->endloop();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue