use Sip::MsgType;
use File::Queue;
-use Storable qw(freeze thaw);
+use FreezeThaw qw(freeze thaw);
my $mp_fifo = File::Queue->new( File => "/tmp/SIPServer.mulitplex-fifo.$$" );
END { $mp_fifo->delete };
my %active_connections;
sub PERMAFROST {
while (my $login = $mp_fifo->deq) {
- $login = thaw($login);
+ ($login) = thaw($login);
+
+ my $c = $$login{id};
if ($$login{success}) {
- $active_connections{$$login{id}} = $login;
+ for my $p (keys %{ $$login{net_server_parts} }) {
+ $active_connections{$c}{net_server}{$p} =
+ $$login{net_server_parts}{$p};
+ }
} else {
- delete $active_connections{$$login{id}};
+ delete $active_connections{$c};
}
}
}
}
# We stick this here, assuming success. Cleanup comes later via PERMAFROST().
- $active_connections{$conn_id} = { id => $conn_id, transport => $transport };
+ $active_connections{$conn_id} = { id => $conn_id, transport => $transport, net_server => $self };
my $pid = fork();
if (!defined($pid) or $pid < 0) {
if ($@) {
syslog('LOG_ERR', "ILS login error: $@");
$success = 0;
- exit(0);
- }
-
- # Evergreen, at least, needs a chance to clean up before forking for other requests
- $self->{ils}->disconnect() if (UNIVERSAL::can($self->{ils},'disconnect'));
+ } else {
+ # Grab any state data for later
+ $self->{state} = $self->{ils}->state() if (UNIVERSAL::can($self->{ils},'state'));
+
+ # Evergreen, at least, needs a chance to clean up before forking for other requests
+ $self->{ils}->disconnect() if (UNIVERSAL::can($self->{ils},'disconnect'));
- # Stash the ILS module somewhere handy for later
- $self->{ils} = ref($self->{ils});
+ # Stash the ILS module somewhere handy for later
+ $self->{ils} = ref($self->{ils});
+ }
$mp_fifo->enq(
freeze({
id => $conn_id,
success => $success,
- transport => $transport,
- net_server => bless({%$self}, ref($self))
+ net_server_parts => {
+ map { ($_ => $$self{$_}) } qw/ils state institution account/
+ }
})
);
if ($pid == 0) { # in kid
# build the connection we deleted after logging in
- $self->{ils} = $active_connections{$conn_id}->{ils}->new($self->{institution}, $self->{account}, $active_connections{$conn_id}->{state});
+ $self->{ils} = $self->{ils}->new($self->{institution}, $self->{account}, $self->{state});
if (!$self->{ils}) {
syslog('LOG_ERR', "Unable to build ILS module in mux child");