diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm index 7e9c620218..e891a054e2 100755 --- a/C4/SIP/SIPServer.pm +++ b/C4/SIP/SIPServer.pm @@ -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; } }