Subject: | unable to connect after restarting Multiplex server |
I am unable to connect to a Net::Server::Multiplex server after a restart. It looks like the socket is reused, but i cant connect anymore.
I attched a small file to reproduce the bug:
1.) start the server
2.) send a HUP to the server
3.) try to connect:
telnet 127.0.0.1 10033
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
any ideas why?
Best regards,
Dietmar
#!/usr/bin/perl -w
use strict;
use Carp;
use Getopt::Long;
use Sys::Syslog;
#use File::Path;
use Net::Server::Multiplex;
use Fcntl ':flock';
use vars qw(@ISA);
@ISA = qw(Net::Server::Multiplex);
my $opt_commandline = [$0, @ARGV];
my $opt_policy_port = 10033;
my $opt_testmode;
my $opt_pidfile;
my $opt_database;
if (!GetOptions ('pidfile=s' => \$opt_pidfile,
'testmode' => \$opt_testmode,
'database=s' => \$opt_database)) {
die "usage error\n";
exit (-1);
}
# try to get the lock
my $lckfn = "/var/run/multiplex-text.lock";
open (FLCK, ">>$lckfn") ||
die ("can't open lock file '$lckfn' - $! : ERROR");
flock (FLCK, LOCK_EX|LOCK_NB) ||
die ("can't aquire lock '$lckfn' - $! : ERROR");
my $server_attr = {
port => [ $opt_policy_port ],
host => '127.0.0.1',
log_level => 5,
log_file => 'Sys::Syslog',
syslog_logsock => 'unix',
syslog_facility => 'mail',
syslog_ident => 'multiplex-text',
commandline => $opt_commandline,
};
sub mux_input {
my ($self, $mux, $fh, $dataref) = @_;
my $prop = $self->{server};
my $netserver = $self->{net_server};
$netserver->log (0, "got $$dataref");
$$dataref = "";
}
my $server = bless {
server => $server_attr,
};
$server->run ();
exit (0);