my $values = $cache->get_multi(@keys);
for my $key (keys %$values) {
-
my $VAR1; # for Dump() -> eval;
eval $values->{$key}; # Data::Dumper->Dump string
if ($pid == 0) { # in kid
- eval { &$transport($self, $str_fh) };
+ $cache = undef; # don't use the same cache handle as our parent.
+ my $cache_data = {id => $conn_id};
- my $success = 1;
- if ($@) {
- syslog('LOG_ERR', "ILS login error: $@");
- $success = 0;
- } else {
- # Grab any state data for later
- $self->{state} = $self->{ils}->state() if (UNIVERSAL::can($self->{ils},'state'));
+ # Once the login dance is complete in SipMsg, login_complete() is
+ # called so that we may cache the results before the login response
+ # message is delivered to the client.
+ $self->{login_complete} = sub {
+ my $status = shift;
- # Evergreen, at least, needs a chance to clean up before forking for other requests
- $self->{ils}->disconnect() if (UNIVERSAL::can($self->{ils},'disconnect'));
+ if ($status) { # login OK
- # Stash the ILS module somewhere handy for later
- $self->{ils} = ref($self->{ils});
- }
-
- my $info = {
- id => $conn_id,
- success => $success,
- net_server_parts => {
- map { ($_ => $$self{$_}) } qw/ils state institution account/
+ $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});
+
+ $cache_data->{success} = 1;
+ $cache_data->{net_server_parts} = {
+ map { ($_ => $$self{$_}) } qw/ils state institution account/
+ };
+ } else {
+ $cache_data->{success} = 0;
}
+
+ init_cache()->set(
+ "sip_pending_auth_$$",
+ Data::Dumper->Dump([$cache_data]),
+ # Our cache entry is only inspected when the parent process
+ # wakes up from an inbound request. If this is the last child
+ # to connect before a long period of inactivity, our cache
+ # entry may sit unnattended for some time, hence the
+ # 12 hour cache timeout. XXX: make it configurable?
+ 43200 # 12 hours
+ );
+
+ $self->{login_complete_called} = 1;
};
- init_cache()->set(
- "sip_pending_auth_$$",
- Data::Dumper->Dump([$info]),
- # Our cache entry is only inspected when the parent process
- # wakes up from an inbound request. If this is the last child
- # to connect before a long period of inactivity, our cache
- # entry may sit unnattended for some time, hence the
- # 12 hour cache timeout. XXX: make it configurable?
- 43200 # 12 hours
- );
-
+ eval { &$transport($self, $str_fh) };
+
+ if ($@) {
+ syslog('LOG_ERR', "ILS login error: $@");
+ $self->{login_complete}->(0) unless $self->{login_complete_called};
+ }
+
exit(0);
} else {
if ($pid == 0) { # in kid
# build the connection we deleted after logging in
- $self->{ils}->use;
+ $self->{ils}->use; # module name in the parent
$self->{ils} = $self->{ils}->new($self->{institution}, $self->{account}, $self->{state});
# MUX mode only works with protocol version 2, because it assumes