Bug 13432 - SIP Server does not respect timeout setting

Koha's SIP server accepts timeout parameters, but those parameters
are only used for the login portion of a telnet transport session.
Other than that, they are ignored, and as long as whatever opened
the connection keeps it open, it will stay open indefinitely.

Test Plan:
1) Set the timeout setting on your SIP server to 10 seconds
2) Modify misc/sip_cli_emulator.pl, add "sleep 100;" directly after line 91
3) Start your SIP server
4) Run the modified sip script with valid parameters
5) Watch the SIP server stderr
6) Note that even though the script waits far too long before continuing,
   the SIP server never kills the connection, and the requests the cli
   script makes come back with valid data.
7) Apply this patch
8) Restart your SIP server
9) Repeat step 4
10) Note that this time you see "SIP Timed Out!" in the SIP server
    stderr and when the script finally makes it's request, it doesn't
    come back with valid data.

Signed-off-by: Colin Campbell <colin.campbell@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Kyle M Hall 2014-12-10 12:27:59 -05:00 committed by Tomas Cohen Arazi
parent f4f1f5a3b3
commit 03335ab401
1 changed files with 4 additions and 0 deletions

View File

@ -238,6 +238,7 @@ sub sip_protocol_loop {
my $self = shift;
my $service = $self->{service};
my $config = $self->{config};
my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30;
my $input;
# The spec says the first message will be:
@ -254,8 +255,10 @@ sub sip_protocol_loop {
#
# In short, we'll take any valid message here.
#my $expect = SC_STATUS;
local $SIG{ALRM} = sub { die "SIP Timed Out!\n"; };
my $expect = '';
while (1) {
alarm $timeout;
$input = Sip::read_SIP_packet(*STDIN);
unless ($input) {
return; # EOF
@ -281,6 +284,7 @@ sub sip_protocol_loop {
}
# We successfully received and processed what we were expecting
$expect = '';
alarm 0;
}
}