[OpenSRF-GIT] OpenSRF branch master updated. 4319d23a331fadd5bd515d4a78154cc829d13981
Evergreen Git
git at git.evergreen-ils.org
Mon Mar 12 11:41:13 EDT 2012
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".
The branch, master has been updated
via 4319d23a331fadd5bd515d4a78154cc829d13981 (commit)
from 974d3a0dd4ddd134033b16bcd9e2fde34302ffd5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4319d23a331fadd5bd515d4a78154cc829d13981
Author: Bill Erickson <berick at esilibrary.com>
Date: Mon Feb 20 14:40:30 2012 -0500
Detect remote disconnect in Perl XMPP reader
When the jabber server severs the connection, it leaves the Perl libs
with a socket that perpetually appears ready for reading, but always
returns 0 bytes. This produces a loop in the client code. This change
detects this situation, logs an error, and throws an exception.
Signed-off-by: Bill Erickson <berick at esilibrary.com>
Signed-off-by: Dan Scott <dscott at laurentian.ca>
diff --git a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm
index 556f597..b8a5da1 100644
--- a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm
+++ b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm
@@ -5,6 +5,7 @@ use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
use Time::HiRes qw/time/;
use OpenSRF::Transport::SlimJabber::XMPPMessage;
use OpenSRF::Utils::Logger qw/$logger/;
+use OpenSRF::EX;
# -----------------------------------------------------------
# Connect, disconnect, and authentication messsage templates
@@ -211,15 +212,25 @@ sub wait {
my $buf;
my $read_size = 1024;
my $nonblock = 0;
+ my $nbytes;
+ my $first_read = 1;
- while(my $n = sysread($socket, $buf, $read_size)) {
+ while($nbytes = sysread($socket, $buf, $read_size)) {
$self->{parser}->parse_more($buf) if $buf;
- if($n < $read_size or $self->peek_msg) {
+ if($nbytes < $read_size or $self->peek_msg) {
set_block($socket) if $nonblock;
last;
}
set_nonblock($socket) unless $nonblock;
$nonblock = 1;
+ $first_read = 0;
+ }
+
+ if ($nbytes == 0 and $first_read) {
+ # if the first read on an active socket is 0 bytes,
+ # the socket has been disconnected from the remote end.
+ $logger->error("Disconnected from Jabber server");
+ throw OpenSRF::EX::Jabber("Disconnected from Jabber server");
}
return $self->next_msg;
-----------------------------------------------------------------------
Summary of changes:
.../lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
hooks/post-receive
--
OpenSRF
More information about the opensrf-commits
mailing list