From aa5b14ca1e6e51dbe79895326ea51af212b2634b Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 29 Apr 2007 19:16:52 +0000 Subject: [PATCH] Added timeout to upload tracker --- uptracker.cgi | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/uptracker.cgi b/uptracker.cgi index 209c3591c..3a76fc765 100755 --- a/uptracker.cgi +++ b/uptracker.cgi @@ -36,7 +36,8 @@ else { $upfile = "$ENV{'WEBMIN_VAR'}/upload.$id"; } -# Read the tracker file in a loop until done +# Read the tracker file in a loop until done, or until 1 minute has passed +# with no progress print "\n"; @@ -55,6 +56,23 @@ while(1) { print "\n"; last; } + + # Check if there has been no activity for 60 seconds + $now = time(); + if ($size == $last_size) { + if ($last_time && $last_time < $now-60) { + # Too slow! Give up + print "\n"; + last; + } + } + else { + $last_size = $size; + $last_time = $now; + } + $pc = int(100 * $size / $totalsize) / 2; next if (defined($lastpc) && $pc == $lastpc); print "