Skip to content

Commit

Permalink
Add a timeout via sig alarm when posting data
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Sandin committed Mar 6, 2014
1 parent 6ac630c commit bac6a9b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Linode/Longview/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ our $logger = get_logger();
our $gua;
our $post_target = 'https://longview.linode.com/post';

our $VERSION = '1.1.3';
our $VERSION = '1.1.4';
our $TICKS = POSIX::sysconf(&POSIX::_SC_CLK_TCK);
our $PROCFS = find_procfs() or $logger->logdie("Couldn't find procfs: $!");
our $ARCH = get_architecture() or $logger->info("Couldn't determine architecture: $!");
Expand All @@ -84,6 +84,9 @@ sub get_UA {
sub post {
my $payload = shift;
my $ua = get_UA();
local $SIG{ALRM} = sub { die "LWP-Timeout";};
alarm(180);
$logger->trace("Posting Data");
my $req = $ua->post(
$post_target,
Content_Type => 'form-data',
Expand All @@ -97,6 +100,7 @@ sub post {
]
]
);
alarm(0);
return $req;
}

Expand Down

0 comments on commit bac6a9b

Please sign in to comment.