View | Details | Raw Unified | Return to bug 15006
Collapse All | Expand All

(-)a/C4/SIP/SIPServer.pm (-3 / +4 lines)
Lines 15-20 use C4::SIP::Sip::Constants qw(:all); Link Here
15
use C4::SIP::Sip::Configuration;
15
use C4::SIP::Sip::Configuration;
16
use C4::SIP::Sip::Checksum qw(checksum verify_cksum);
16
use C4::SIP::Sip::Checksum qw(checksum verify_cksum);
17
use C4::SIP::Sip::MsgType qw( handle login_core );
17
use C4::SIP::Sip::MsgType qw( handle login_core );
18
use C4::SIP::Sip qw( get_timeout );
18
19
19
use base qw(Net::Server::PreFork);
20
use base qw(Net::Server::PreFork);
20
21
Lines 128-134 sub raw_transport { Link Here
128
    my $strikes = 3;
129
    my $strikes = 3;
129
130
130
    local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; };
131
    local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; };
131
    my $timeout = $service->{timeout} || 30;
132
    my $timeout = get_timeout( $self, { transport => 1 } );
132
    syslog("LOG_DEBUG", "raw_transport: timeout is %d", $timeout);
133
    syslog("LOG_DEBUG", "raw_transport: timeout is %d", $timeout);
133
134
134
    while( $strikes && ( !$self->{account} || !$self->{account}->{id} )) {
135
    while( $strikes && ( !$self->{account} || !$self->{account}->{id} )) {
Lines 190-196 sub telnet_transport { Link Here
190
    my $account = undef;
191
    my $account = undef;
191
    my $input;
192
    my $input;
192
    my $config  = $self->{config};
193
    my $config  = $self->{config};
193
    my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30;
194
    my $timeout = get_timeout( $self, { transport => 1 } );
194
    syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout);
195
    syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout);
195
196
196
    eval {
197
    eval {
Lines 253-259 sub sip_protocol_loop { Link Here
253
    my $self = shift;
254
    my $self = shift;
254
    my $service = $self->{service};
255
    my $service = $self->{service};
255
    my $config  = $self->{config};
256
    my $config  = $self->{config};
256
    my $timeout = $self->{service}->{client_timeout} || $config->{client_timeout};
257
    my $timeout = get_timeout( $self, { client => 1 } );
257
258
258
    # The spec says the first message will be:
259
    # The spec says the first message will be:
259
    #     SIP v1: SC_STATUS
260
    #     SIP v1: SC_STATUS
(-)a/C4/SIP/Sip.pm (-3 / +27 lines)
Lines 22-35 BEGIN { Link Here
22
	@ISA = qw(Exporter);
22
	@ISA = qw(Exporter);
23
23
24
	@EXPORT_OK = qw(y_or_n timestamp add_field maybe_add add_count
24
	@EXPORT_OK = qw(y_or_n timestamp add_field maybe_add add_count
25
            denied sipbool boolspace write_msg
25
            denied sipbool boolspace write_msg get_timeout
26
		    $error_detection $protocol_version $field_delimiter
26
		    $error_detection $protocol_version $field_delimiter
27
		    $last_response);
27
		    $last_response);
28
28
29
	%EXPORT_TAGS = (
29
	%EXPORT_TAGS = (
30
		    all => [qw(y_or_n timestamp add_field maybe_add
30
		    all => [qw(y_or_n timestamp add_field maybe_add
31
			       add_count denied sipbool boolspace write_msg
31
			       add_count denied sipbool boolspace write_msg
32
			       $error_detection $protocol_version
32
                   get_timeout
33
                   $error_detection $protocol_version
33
			       $field_delimiter $last_response)]);
34
			       $field_delimiter $last_response)]);
34
}
35
}
35
36
Lines 197-200 sub write_msg { Link Here
197
    $last_response = $msg;
198
    $last_response = $msg;
198
}
199
}
199
200
201
# get_timeout( $server, { transport|client => 1, fallback => some_val } );
202
#
203
# Centralizes all timeout logic from SIPServer into one routine
204
205
sub get_timeout {
206
    my ( $server, $params ) = @_;
207
208
    my $fallback = $params->{fallback} || 30;
209
    if( $params->{transport} ) {
210
        # We do not allow zero values here
211
        return $server->{service}->{timeout} || $fallback;
212
    } elsif( $params->{client} ) {
213
        if( exists $server->{policy}->{timeout} ) {
214
        # We do allow zero values here to indicate no timeout
215
            my $val = $server->{policy}->{timeout};
216
            $val = 0 if ! $val > 0; # just precautious
217
            return $val;
218
        }
219
        return $server->{service}->{timeout} || $fallback;
220
    } else {
221
        return $fallback;
222
    }
223
}
224
200
1;
225
1;
201
- 

Return to bug 15006