Bugzilla – Attachment 52850 Details for
Bug 15006
Need to distinguish client timeout from login timeout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15006: [QA Follow-up] Indentation for two subroutines
Bug-15006-QA-Follow-up-Indentation-for-two-subrout.patch (text/plain), 9.39 KB, created by
Kyle M Hall (khall)
on 2016-06-24 17:32:34 UTC
(
hide
)
Description:
Bug 15006: [QA Follow-up] Indentation for two subroutines
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-24 17:32:34 UTC
Size:
9.39 KB
patch
obsolete
>From c6f4ac40d80a43ff57e1c7a107efd2ed1db8c3c7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 17 Jun 2016 11:07:16 +0200 >Subject: [PATCH] Bug 15006: [QA Follow-up] Indentation for two subroutines > >Remove tabs from telnet_transport and sip_protocol_loop. Correct >indentation. > >Test plan: >Compare files before and after without whitespace (diff -b). >Notice only two split lines. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/SIP/SIPServer.pm | 160 ++++++++++++++++++++++++++-------------------------- > 1 file changed, 80 insertions(+), 80 deletions(-) > >diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm >index 8722ab6..0b84c6b 100755 >--- a/C4/SIP/SIPServer.pm >+++ b/C4/SIP/SIPServer.pm >@@ -128,21 +128,21 @@ sub raw_transport { > my $service = $self->{service}; > > while (!$self->{account}) { >- local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; >- syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout}); >- $input = read_SIP_packet(*STDIN); >- if (!$input) { >- # EOF on the socket >- syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); >- return; >- } >- $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) >- last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); >+ local $SIG{ALRM} = sub { die "raw_transport Timed Out!\n"; }; >+ syslog("LOG_DEBUG", "raw_transport: timeout is %d", $service->{timeout}); >+ $input = read_SIP_packet(*STDIN); >+ if (!$input) { >+ # EOF on the socket >+ syslog("LOG_INFO", "raw_transport: shutting down: EOF during login"); >+ return; >+ } >+ $input =~ s/[\r\n]+$//sm; # Strip off trailing line terminator(s) >+ last if C4::SIP::Sip::MsgType::handle($input, $self, LOGIN); > } > > syslog("LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", >- $self->{account}->{id}, >- $self->{account}->{institution}); >+ $self->{account}->{id}, >+ $self->{account}->{institution}); > > $self->sip_protocol_loop(); > syslog("LOG_INFO", "raw_transport: shutting down"); >@@ -179,55 +179,55 @@ sub telnet_transport { > my $account = undef; > my $input; > my $config = $self->{config}; >- my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; >- syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout); >+ my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; >+ syslog("LOG_DEBUG", "telnet_transport: timeout is %s", $timeout); > > eval { >- local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; }; >- local $| = 1; # Unbuffered output >- $/ = "\015"; # Internet Record Separator (lax version) >- # Until the terminal has logged in, we don't trust it >- # so use a timeout to protect ourselves from hanging. >- >- while ($strikes--) { >- print "login: "; >- alarm $timeout; >- # $uid = &get_clean_input; >- $uid = <STDIN>; >- print "password: "; >- # $pwd = &get_clean_input || ''; >- $pwd = <STDIN>; >- alarm 0; >- >- syslog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd)); >- $uid = get_clean_string ($uid); >- $pwd = get_clean_string ($pwd); >- syslog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd)); >- >- if (exists ($config->{accounts}->{$uid}) >- && ($pwd eq $config->{accounts}->{$uid}->{password})) { >- $account = $config->{accounts}->{$uid}; >- if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) { >- last; >+ local $SIG{ALRM} = sub { die "telnet_transport: Timed Out ($timeout seconds)!\n"; }; >+ local $| = 1; # Unbuffered output >+ $/ = "\015"; # Internet Record Separator (lax version) >+ # Until the terminal has logged in, we don't trust it >+ # so use a timeout to protect ourselves from hanging. >+ >+ while ($strikes--) { >+ print "login: "; >+ alarm $timeout; >+ # $uid = &get_clean_input; >+ $uid = <STDIN>; >+ print "password: "; >+ # $pwd = &get_clean_input || ''; >+ $pwd = <STDIN>; >+ alarm 0; >+ >+ syslog("LOG_DEBUG", "telnet_transport 1: uid length %s, pwd length %s", length($uid), length($pwd)); >+ $uid = get_clean_string ($uid); >+ $pwd = get_clean_string ($pwd); >+ syslog("LOG_DEBUG", "telnet_transport 2: uid length %s, pwd length %s", length($uid), length($pwd)); >+ >+ if( exists ($config->{accounts}->{$uid}) && ($pwd eq $config->{accounts}->{$uid}->{password})) { >+ $account = $config->{accounts}->{$uid}; >+ if ( C4::SIP::Sip::MsgType::login_core($self,$uid,$pwd) ) { >+ last; >+ } > } >- } >- syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||'')); >- print("Invalid login$CRLF"); >- } >+ syslog("LOG_WARNING", "Invalid login attempt: '%s'", ($uid||'')); >+ print("Invalid login$CRLF"); >+ } > }; # End of eval > > if ($@) { >- syslog("LOG_ERR", "telnet_transport: Login timed out"); >- die "Telnet Login Timed out"; >+ syslog("LOG_ERR", "telnet_transport: Login timed out"); >+ die "Telnet Login Timed out"; > } elsif (!defined($account)) { >- syslog("LOG_ERR", "telnet_transport: Login Failed"); >- die "Login Failure"; >+ syslog("LOG_ERR", "telnet_transport: Login Failed"); >+ die "Login Failure"; > } else { >- print "Login OK. Initiating SIP$CRLF"; >+ print "Login OK. Initiating SIP$CRLF"; > } > > $self->{account} = $account; >- syslog("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", $account->{id}, $account->{institution}); >+ syslog("LOG_DEBUG", "telnet_transport: uname/inst: '%s/%s'", >+ $account->{id}, $account->{institution}); > $self->sip_protocol_loop(); > syslog("LOG_INFO", "telnet_transport: shutting down"); > } >@@ -238,15 +238,15 @@ sub telnet_transport { > # telnet transport. From that point on, both the raw and the telnet > # processes are the same: > sub sip_protocol_loop { >- my $self = shift; >- my $service = $self->{service}; >- my $config = $self->{config}; >+ my $self = shift; >+ my $service = $self->{service}; >+ my $config = $self->{config}; > my $timeout = $self->{service}->{timeout} || $config->{timeout} || 30; >- my $input; >+ my $input; > > # The spec says the first message will be: >- # SIP v1: SC_STATUS >- # SIP v2: LOGIN (or SC_STATUS via telnet?) >+ # SIP v1: SC_STATUS >+ # SIP v2: LOGIN (or SC_STATUS via telnet?) > # But it might be SC_REQUEST_RESEND. As long as we get > # SC_REQUEST_RESEND, we keep waiting. > >@@ -254,41 +254,41 @@ sub sip_protocol_loop { > # constraint, so we'll relax about it too. > # Using the SIP "raw" login process, rather than telnet, > # requires the LOGIN message and forces SIP 2.00. In that >- # case, the LOGIN message has already been processed (above). >- # >- # In short, we'll take any valid message here. >- #my $expect = SC_STATUS; >+ # case, the LOGIN message has already been processed (above). >+ # >+ # 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 = read_SIP_packet(*STDIN); > unless ($input) { >- return; # EOF >+ return; # EOF > } >- # begin input hacks ... a cheap stand in for better Telnet layer >- $input =~ s/^[^A-z0-9]+//s; # Kill leading bad characters... like Telnet handshakers >- $input =~ s/[^A-z0-9]+$//s; # Same on the end, should get DOSsy ^M line-endings too. >- while (chomp($input)) {warn "Extra line ending on input";} >- unless ($input) { >+ # begin input hacks ... a cheap stand in for better Telnet layer >+ $input =~ s/^[^A-z0-9]+//s; # Kill leading bad characters... like Telnet handshakers >+ $input =~ s/[^A-z0-9]+$//s; # Same on the end, should get DOSsy ^M line-endings too. >+ while (chomp($input)) {warn "Extra line ending on input";} >+ unless ($input) { > syslog("LOG_ERR", "sip_protocol_loop: empty input skipped"); > print("96$CR"); > next; >- } >- # end cheap input hacks >- my $status = handle($input, $self, $expect); >- if (!$status) { >- syslog("LOG_ERR", "sip_protocol_loop: failed to handle %s",substr($input,0,2)); >- } >- next if $status eq REQUEST_ACS_RESEND; >- if ($expect && ($status ne $expect)) { >- # We received a non-"RESEND" that wasn't what we were expecting. >- syslog("LOG_ERR", "sip_protocol_loop: expected %s, received %s, exiting", $expect, $input); >- } >- # We successfully received and processed what we were expecting >- $expect = ''; >+ } >+ # end cheap input hacks >+ my $status = handle($input, $self, $expect); >+ if (!$status) { >+ syslog("LOG_ERR", "sip_protocol_loop: failed to handle %s",substr($input,0,2)); >+ } >+ next if $status eq REQUEST_ACS_RESEND; >+ if ($expect && ($status ne $expect)) { >+ # We received a non-"RESEND" that wasn't what we were expecting. >+ syslog("LOG_ERR", "sip_protocol_loop: expected %s, received %s, exiting", $expect, $input); >+ } >+ # We successfully received and processed what we were expecting >+ $expect = ''; > alarm 0; >- } >+ } > } > > 1; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15006
:
45039
|
45583
|
45594
|
52477
|
52478
|
52479
|
52480
|
52784
|
52785
|
52786
|
52787
|
52849
|
52850
|
52851
|
52852
|
52853
|
53009
|
53010
|
53011
|
53012
|
53013
|
53014
|
53132
|
53133
|
53134
|
53135
|
53309
|
53310
|
53311
|
53312
|
53355
|
53356
|
53357
|
53358
|
53359
|
53360
|
53363
|
53364
|
53365
|
53366
|
53367
|
53368
|
53369