r3816 - trunk/varnish-tools/webgui

petter at projects.linpro.no petter at projects.linpro.no
Mon Feb 23 15:51:44 CET 2009


Author: petter
Date: 2009-02-23 15:51:43 +0100 (Mon, 23 Feb 2009)
New Revision: 3816

Modified:
   trunk/varnish-tools/webgui/start.pl
Log:
Don't use a 500 status as a hint to quit the data collector thread. Tell it by a shared variable.


Modified: trunk/varnish-tools/webgui/start.pl
===================================================================
--- trunk/varnish-tools/webgui/start.pl	2009-02-23 14:12:33 UTC (rev 3815)
+++ trunk/varnish-tools/webgui/start.pl	2009-02-23 14:51:43 UTC (rev 3816)
@@ -1,5 +1,6 @@
 #!/usr/bin/perl
 use threads;
+use threads::shared;
 use strict;
 use warnings;
 use HTTP::Daemon;
@@ -68,6 +69,8 @@
 }
 log_info("HTTP daemon started with URL " . $daemon->url);
 print "Web server started with URL: " . $daemon->url, "\n";
+my $running :shared;
+$running = 1;
 my $data_collector_handle = threads->create('data_collector_thread');
 while (my $connection = $daemon->accept) {
 	REQUEST:
@@ -105,6 +108,7 @@
 }
 log_info("Shutting down web server");
 $daemon->close();
+$running = 0;
 Varnish::DB->finish();
 log_info("Stopping data collector thread");
 $data_collector_handle->join();
@@ -117,11 +121,12 @@
 	sleep 1; # wait for the server to come up
 	while (1) {
 		my $user_agent = LWP::UserAgent->new;
+
 		$user_agent->timeout(10);
 		my $response = $user_agent->get($url);
-			
-		last if ($response->code eq "500");
 		sleep($interval);
+
+		last if (!$running);
 	}
 	print "Data collector thread stopped.\n";
 }



More information about the varnish-commit mailing list