Commit eb312189 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add a SetTimeout call so that RPCs can be given a timeout.

parent ecb214c1
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2008 University of Utah and the Flux Group.
# Copyright (c) 2008-2009 University of Utah and the Flux Group.
# All rights reserved.
#
# Perl code to access an XMLRPC server using http. Derived from the
......@@ -26,7 +26,10 @@ use HTTP::Request::Common qw(POST);
use HTTP::Headers;
use Data::Dumper;
my $debug = 1;
my $debug = 1;
# Let the caller set a timeout for a call.
my $timeout = 0;
##
# The package version number
......@@ -120,6 +123,13 @@ sub GetContext($)
return $MyContext;
}
sub SetTimeout($$)
{
my ($class, $to) = @_;
$timeout = $to;
return 0;
}
#
# Call to a non-Emulab xmlrpc server.
......@@ -192,6 +202,8 @@ sub CallMethod($$$@)
#
my $reqstr = $request->as_string();
my $ua = LWP::UserAgent->new();
$ua->timeout($timeout)
if ($timeout > 0);
my $hreq = HTTP::Request->new(POST => $httpURL);
$hreq->content_type('text/xml');
$hreq->content($reqstr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment