Lines 124-148
sub process_request {
Link Here
|
124 |
|
124 |
|
125 |
sub raw_transport { |
125 |
sub raw_transport { |
126 |
my $self = shift; |
126 |
my $self = shift; |
127 |
my ($input); |
127 |
my $input; |
128 |
my $service = $self->{service}; |
128 |
my $service = $self->{service}; |
|
|
129 |
# If using Net::Server::PreFork you may already have account set from a previous session |
130 |
# Ensure you dont |
131 |
if ($self->{account}) { |
132 |
delete $self->{account}; |
133 |
} |
129 |
|
134 |
|
|
|
135 |
# Timeout the while loop if we get stuck in it |
136 |
# In practice it should only iterate once but be prepared |
137 |
local $SIG{ALRM} = sub { die 'raw transport Timed Out!' } |
138 |
syslog('LOG_DEBUG', "raw_transport: timeout is $service->{timeout}"); |
139 |
alarm $service->{timeout}; |
130 |
while (!$self->{account}) { |
140 |
while (!$self->{account}) { |
131 |
local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; |
141 |
$input = read_request(); |
132 |
syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout}); |
142 |
if (!$input) { |
133 |
$input = read_request(); |
143 |
# EOF on the socket |
134 |
if (!$input) { |
144 |
syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); |
135 |
# EOF on the socket |
145 |
return; |
136 |
syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); |
146 |
} |
137 |
return; |
147 |
$input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) |
138 |
} |
148 |
last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); |
139 |
$input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) |
|
|
140 |
last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); |
141 |
} |
149 |
} |
|
|
150 |
alarm 0; |
142 |
|
151 |
|
143 |
syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", |
152 |
syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", |
144 |
$self->{account}->{id}, |
153 |
$self->{account}->{id}, |
145 |
$self->{account}->{institution}); |
154 |
$self->{account}->{institution}); |
|
|
155 |
if (! $self->{account}->{id}) { |
156 |
syslog("LOG_ERR","Login failed shutting down"); |
157 |
return; |
158 |
} |
146 |
|
159 |
|
147 |
$self->sip_protocol_loop(); |
160 |
$self->sip_protocol_loop(); |
148 |
syslog("LOG_INFO", "raw_transport: shutting down"); |
161 |
syslog("LOG_INFO", "raw_transport: shutting down"); |
149 |
- |
|
|