From 6450f74c031428efe6f631c44756bce77232cca1 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 7 Apr 2011 20:51:18 +0000 Subject: [PATCH] correct timeout handling --- templates/gnuplot.html.ep | 2 +- web_ui.pl | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/templates/gnuplot.html.ep b/templates/gnuplot.html.ep index e4544e9..65435a4 100644 --- a/templates/gnuplot.html.ep +++ b/templates/gnuplot.html.ep @@ -2,7 +2,7 @@ <%= form_for gnuplot => begin %> <%= text_area 'sql', cols => 80, rows => 5 %>
with <%= select_field with => [qw(dots points steps lines)], 'dots' %> - timeout <%= text_field 'timeout', value => 5, style => 'width: 2em' %>s + timeout <%= input_tag 'timeout', type => 'number', style => 'width: 3em' %>s <%= submit_button 'execute' %> <%= check_box 'include_gnuplot' => 1, title => 'include gnuplot dump' %> <% end %> diff --git a/web_ui.pl b/web_ui.pl index 21553c2..59752b9 100755 --- a/web_ui.pl +++ b/web_ui.pl @@ -79,13 +79,20 @@ get '/gnuplot' => sub { my $self = shift; my $sql = $self->param('sql'); + + if ( my $timeout = $self->param('timeout') ) { + warn "set timout to $timeout"; + $gearman->timeout( $timeout ); + } else { + $self->param( timeout => $gearman->timeout ); + } + return $self->render('gnuplot', img => '', gnuplot => '') unless $sql; # re-format SQL $sql =~ s/\s+(from|where|order|limit|join)/\n$1/gs; $self->param( sql => $sql ); - $gearman->timeout( $self->param('timeout') ); my $ret = $gearman->req( 'SUBMIT_JOB', 'Store_sql', '', $sql ); die "no result for $sql" unless $ret; -- 2.20.1