From: erickson Date: Tue, 28 Jul 2009 20:27:42 +0000 (+0000) Subject: reduce unnecessary calls to fcntl() while reading from the socket X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=064035c537115a406d9588ccdc5674dd1414f8ca;p=working%2FOpenSRF.git reduce unnecessary calls to fcntl() while reading from the socket git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1729 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm index 7630635..c2d5cbb 100644 --- a/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm +++ b/src/perl/lib/OpenSRF/Transport/SlimJabber/XMPPReader.pm @@ -208,13 +208,15 @@ sub wait { # now slurp the data off the socket my $buf; my $read_size = 1024; + my $nonblock = 0; while(my $n = sysread($socket, $buf, $read_size)) { $self->{parser}->parse_more($buf) if $buf; if($n < $read_size or $self->peek_msg) { - set_block($socket); + set_block($socket) if $nonblock; last; } - set_nonblock($socket); + set_nonblock($socket) unless $nonblock; + $nonblock = 1; } return $self->next_msg;