adding ability to set recv_timeout per session
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 5 May 2006 20:48:57 +0000 (20:48 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 5 May 2006 20:48:57 +0000 (20:48 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@711 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/AppSession.pm

index 0ed1271..72ff06c 100644 (file)
@@ -721,16 +721,16 @@ sub recv {
        }
 
        while ( $self->{remaining_recv_timeout} > 0 and $avail < $args{count} ) {
-               last if $self->complete;
-               my $starttime = time;
-               $self->queue_wait($self->{remaining_recv_timeout});
-               my $endtime = time;
-               if ($self->{timeout_reset}) {
-                       $self->{timeout_reset} = 0;
-               } else {
-                       $self->{remaining_recv_timeout} -= ($endtime - $starttime)
-               }
-               $avail = @{ $self->{recv_queue} };
+                       last if $self->complete;
+                       my $starttime = time;
+                       $self->queue_wait($self->{remaining_recv_timeout});
+                       my $endtime = time;
+                       if ($self->{timeout_reset}) {
+                               $self->{timeout_reset} = 0;
+                       } else {
+                               $self->{remaining_recv_timeout} -= ($endtime - $starttime)
+                       }
+                       $avail = @{ $self->{recv_queue} };
        }
 
 
@@ -827,6 +827,16 @@ sub new {
        return $self;
 }
 
+sub recv_timeout {
+       my $self = shift;
+       my $timeout = shift;
+       if (defined $timeout) {
+               $self->{recv_timeout} = $timeout;
+               $self->{remaining_recv_timeout} = $timeout;
+       }
+       return $self->{recv_timeout};
+}
+
 sub queue_size {
        my $size = @{$_[0]->{recv_queue}};
        return $size;