[master] 7701175 make the update interval a double to allow values < 1

Nils Goroll nils.goroll at uplex.de
Fri Aug 29 18:05:11 CEST 2014


commit 77011756f6619a7f31948887d1ea8cb5acdb778e
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