[4.0] 765124a make the update interval a double to allow values < 1

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:25 CEST 2014


commit 765124a841b5249a6a1b83b0f27cbdad71064702
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Fri Aug 29 18:04:56 2014 +0200

    make the update interval a double to allow values < 1

diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c
index 6fa7cc7..2f41daa 100644
--- a/bin/varnishstat/varnishstat.c
+++ b/bin/varnishstat/varnishstat.c
@@ -273,7 +273,8 @@ main(int argc, char * const *argv)
 {
 	int c;
 	struct VSM_data *vd;
-	int delay = 1, once = 0, xml = 0, json = 0, do_repeat = 0, f_list = 0;
+	double delay = 1.0;
+	int   once = 0, xml = 0, json = 0, do_repeat = 0, f_list = 0;
 
 	vd = VSM_New();
 
@@ -290,7 +291,7 @@ main(int argc, char * const *argv)
 			exit(0);
 		case 'w':
 			do_repeat = 1;
-			delay = atoi(optarg);
+			delay = atof(optarg);
 			break;
 		case 'x':
 			xml = 1;
@@ -332,7 +333,7 @@ main(int argc, char * const *argv)
 		// end of output block marker.
 		printf("\n");
 
-		sleep(delay);
+		usleep(delay * 1e6);
 	}
 	exit(0);
 }
diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h
index 89dee92..18d3def 100644
--- a/bin/varnishstat/varnishstat.h
+++ b/bin/varnishstat/varnishstat.h
@@ -35,4 +35,4 @@
 #include "vas.h"
 #include "vcs.h"
 
-void do_curses(struct VSM_data *vd, int delay);
+void do_curses(struct VSM_data *vd, double delay);
diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c
index 8ce35f1..4d63e71 100644
--- a/bin/varnishstat/varnishstat_curses.c
+++ b/bin/varnishstat/varnishstat_curses.c
@@ -908,7 +908,7 @@ handle_keypress(int ch)
 }
 
 void
-do_curses(struct VSM_data *vd, int delay)
+do_curses(struct VSM_data *vd, double delay)
 {
 	struct pollfd pollfd;
 	long t;



More information about the varnish-commit mailing list