added error message for cached data on a closed socket
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 22 May 2006 18:18:32 +0000 (18:18 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 22 May 2006 18:18:32 +0000 (18:18 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@721 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/Transport/SlimJabber/Client.pm

index 075afcf..e646fc1 100644 (file)
@@ -578,7 +578,7 @@ sub flush_socket {
        my $self = shift;
        my $socket = $self->{_socket};
 
-       if( $socket and $socket->connected() ) {
+       if( $socket ) {
 
                my $buf;
                my      $flags = fcntl($socket, F_GETFL, 0);
@@ -586,9 +586,14 @@ sub flush_socket {
                fcntl($socket, F_SETFL, $flags | O_NONBLOCK);
                while( my $n = sysread( $socket, $buf, 8192 ) ) {
                        $logger->debug("flush_socket dropped $n bytes of data");
+                       if(!$socket->connected()) {
+                               $logger->error("flush_socket dropped data on disconnected socket: $buf");
+                       }
                }
                fcntl($socket, F_SETFL, $flags);
 
+               return 0 unless $socket->connected();
+
                return 1;
 
        } else {