Fix a bug with Perl's TSocket and THttpClient.
authorDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 19:45:24 +0000 (19:45 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 19:45:24 +0000 (19:45 +0000)
The underlying Perl library expects timeouts in seconds, but the
documentation for the Thrift classes says the should be in milliseconds.
This changes divides timeouts by 1000 to make that the case.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665585 13f79535-47bb-0310-9956-ffa450edef68

lib/perl/lib/Thrift/HttpClient.pm
lib/perl/lib/Thrift/Socket.pm

index 9f79838..f8a583d 100644 (file)
@@ -164,7 +164,7 @@ sub flush
 {
     my $self = shift;
 
-    my $ua = LWP::UserAgent->new('timeout' => $self->{sendTimeout},
+    my $ua = LWP::UserAgent->new('timeout' => ($self->{sendTimeout} / 1000),
       'agent' => 'Perl/THttpClient'
      );
     $ua->default_header('Accept' => 'application/x-thrift');
index 83daf4b..740e048 100644 (file)
@@ -139,7 +139,7 @@ sub readAll
     while (1) {
 
         #check for timeout
-        my @sockets = $self->{handle}->can_read( $self->{recvTimeout} );
+        my @sockets = $self->{handle}->can_read( $self->{recvTimeout} / 1000 );
 
         if(@sockets == 0){
             die new Thrift::TException('TSocket: timed out reading '.$len.' bytes from '.
@@ -179,7 +179,7 @@ sub read
     my $len  = shift;
 
     #check for timeout
-    my @sockets = $self->{handle}->can_read( $self->{sendTimeout} );
+    my @sockets = $self->{handle}->can_read( $self->{sendTimeout} / 1000 );
 
     if(@sockets == 0){
         die new Thrift::TException('TSocket: timed out reading '.$len.' bytes from '.
@@ -217,7 +217,7 @@ sub write
 
 
         #check for timeout
-        my @sockets = $self->{handle}->can_write( $self->{recvTimeout} );
+        my @sockets = $self->{handle}->can_write( $self->{recvTimeout} / 1000 );
 
         if(@sockets == 0){
             die new Thrift::TException('TSocket: timed out writing to bytes from '.