From: miker Date: Fri, 5 May 2006 20:48:57 +0000 (+0000) Subject: adding ability to set recv_timeout per session X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=09389a7e5e8dad94c762b30659a982439f156fb0;p=opensrf%2Fbjwebb.git adding ability to set recv_timeout per session git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@711 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/OpenSRF/AppSession.pm b/src/perlmods/OpenSRF/AppSession.pm index 0ed1271..72ff06c 100644 --- a/src/perlmods/OpenSRF/AppSession.pm +++ b/src/perlmods/OpenSRF/AppSession.pm @@ -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;