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

(-)a/C4/SIP/SIPServer.pm (-28 / +13 lines)
Lines 35-41 BEGIN { Link Here
35
my %transports = (
35
my %transports = (
36
    RAW    => \&raw_transport,
36
    RAW    => \&raw_transport,
37
    telnet => \&telnet_transport,
37
    telnet => \&telnet_transport,
38
    # http   => \&http_transport,	# for http just use the OPAC
39
);
38
);
40
39
41
#
40
#
Lines 126-156 sub raw_transport { Link Here
126
    my $self = shift;
125
    my $self = shift;
127
    my ($input);
126
    my ($input);
128
    my $service = $self->{service};
127
    my $service = $self->{service};
129
    my $strikes = 3;
130
128
131
    eval {
129
    while (!$self->{account}) {
132
		local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; };
130
	local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; };
133
		syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout});
131
	syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout});
134
		while ($strikes--) {
132
	$input = Sip::read_SIP_packet(*STDIN);
135
		    alarm $service->{timeout};
133
	if (!$input) {
136
		    $input = Sip::read_SIP_packet(*STDIN);
134
		# EOF on the socket
137
		    alarm 0;
135
		syslog("LOG_INFO", "raw_transport: shutting down: EOF during login");
138
			if (!$input) {
136
		return;
139
				# EOF on the socket
137
	}
140
				syslog("LOG_INFO", "raw_transport: shutting down: EOF during login");
138
	$input =~ s/[\r\n]+$//sm;	# Strip off trailing line terminator(s)
141
				return;
139
	last if Sip::MsgType::handle($input, $self, LOGIN);
142
		    }
143
		    $input =~ s/[\r\n]+$//sm;	# Strip off trailing line terminator(s)
144
		    last if Sip::MsgType::handle($input, $self, LOGIN);
145
		}
146
	};
147
148
    if (length $@) {
149
		syslog("LOG_ERR", "raw_transport: LOGIN ERROR: '$@'");
150
		die "raw_transport: login error (timeout? $@), exiting";
151
    } elsif (!$self->{account}) {
152
		syslog("LOG_ERR", "raw_transport: LOGIN FAILED");
153
		die "raw_transport: Login failed (no account), exiting";
154
    }
140
    }
155
141
156
    syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'",
142
    syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'",
Lines 272-279 sub sip_protocol_loop { Link Here
272
    while (1) {
258
    while (1) {
273
    		$input = Sip::read_SIP_packet(*STDIN);
259
    		$input = Sip::read_SIP_packet(*STDIN);
274
    		unless ($input) {
260
    		unless ($input) {
275
    			print("96$CR");
261
    			return;		# EOF
276
    			next;
277
    		}
262
    		}
278
		# begin input hacks ...  a cheap stand in for better Telnet layer
263
		# begin input hacks ...  a cheap stand in for better Telnet layer
279
		$input =~ s/^[^A-z0-9]+//s;	# Kill leading bad characters... like Telnet handshakers
264
		$input =~ s/^[^A-z0-9]+//s;	# Kill leading bad characters... like Telnet handshakers
Lines 281-286 sub sip_protocol_loop { Link Here
281
		while (chomp($input)) {warn "Extra line ending on input";}
266
		while (chomp($input)) {warn "Extra line ending on input";}
282
		unless ($input) {
267
		unless ($input) {
283
			syslog("LOG_ERR", "sip_protocol_loop: empty input skipped");
268
			syslog("LOG_ERR", "sip_protocol_loop: empty input skipped");
269
			print("96$CR");
284
			next;
270
			next;
285
		}
271
		}
286
		# end cheap input hacks
272
		# end cheap input hacks
287
- 

Return to bug 7787