From 4f137bb67e847d769eb03ce6e4470496b6b02438 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Fri, 20 Nov 2015 12:12:48 +0000 Subject: [PATCH] Bug 15006 Sip separate global from login timeouts Timeout logic has been added to the main sip loop However the timeout parameter was initially for the login process which requires a short duration applying such a brief timeout to the main sip loop causes instability in many selfcheck units Most selfchecks have persistent connections and send a periodic status request at intervals (approx every 5mins appears the norm) The timeout was dropping connections by default every 30secs which for the client appears as a very flakey network This patch adds a separate parameter client_timeout that can be used if you do want to force a disconnect if the client sends no requests for a period. By not defining it you can switch off the timeout in the main loop, I recommend this unless you have a good reason not too. If you do want this behaviour you can at least now set it to a more realistic value (see sample config file) Removed the commented out html entry in the config file, this was dead code born of a misconception and was just a source of confusion for users --- C4/SIP/SIPServer.pm | 12 ++++++++---- etc/SIPconfig.xml | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 8722ab6..85cfe75 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -241,7 +241,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 $timeout = $self->{service}->{client_timeout} || $config->{client_timeout}; my $input; # The spec says the first message will be: @@ -258,10 +258,12 @@ 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"; }; + local $SIG{ALRM} = sub { die "SIP Timed Out!\n"; } if $timeout; my $expect = ''; while (1) { - alarm $timeout; + if ($timeout) { + alarm $timeout; + } $input = read_SIP_packet(*STDIN); unless ($input) { return; # EOF @@ -287,7 +289,9 @@ sub sip_protocol_loop { } # We successfully received and processed what we were expecting $expect = ''; - alarm 0; + if ($timeout ) { + alarm 0; + } } } diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index 141bc4f..296be3d 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -16,12 +16,6 @@ /> - + + -- 2.5.0