smarter default "recv"
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 20 Apr 2006 03:59:54 +0000 (03:59 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 20 Apr 2006 03:59:54 +0000 (03:59 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@697 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/AppSession.pm

index 9f5099a..caf6b05 100644 (file)
@@ -709,11 +709,17 @@ sub recv {
                $logger->debug( ref($self) ."->recv with timeout " . $args{timeout}, INTERNAL );
        }
 
-       $args{count} ||= 1;
-
        my $avail = @{ $self->{recv_queue} };
        $self->{remaining_recv_timeout} = $self->{recv_timeout};
 
+       if (!$args{count}) {
+               if (wantarray) {
+                       $args{count} = $avail;
+               } else {
+                       $args{count} = 1;
+               }
+       }
+
        while ( $self->{remaining_recv_timeout} > 0 and $avail < $args{count} ) {
                last if $self->complete;
                my $starttime = time;