Commit d1b78e8d authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Terminate varnishtop -d automatically

Following the documentation, the -d option implies that once processing
is done the process should exit. We give it the time to do one last
refresh of the screen in curses mode.

Refs #2686
parent c14650ca
......@@ -12,7 +12,8 @@ client c1 {
rxresp
} -run
shell -expect "fetch" "varnishtop -n ${v1_name} -1 -d"
shell -expect "fetch" "varnishtop -n ${v1_name} -1"
shell -expect "fetch" "varnishtop -n ${v1_name} -d"
shell -match "Usage: .*varnishtop <options>" \
"varnishtop -h"
......
......@@ -77,13 +77,13 @@ struct top {
};
static float period = 60; /* seconds */
static int end_of_file = 0;
static unsigned ntop;
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
static int f_flag = 0;
static unsigned maxfieldlen = 0;
static char *ident;
static volatile sig_atomic_t end_of_file = 0;
static volatile sig_atomic_t quit = 0;
static VRB_HEAD(t_order, top) h_order = VRB_INITIALIZER(&h_order);
......@@ -204,7 +204,7 @@ static void
update(int p)
{
struct top *tp, *tp2;
int l, len;
int l, len, eof;
double t = 0;
static time_t last = 0;
static unsigned n;
......@@ -222,7 +222,8 @@ update(int p)
AC(erase());
q = ident;
len = COLS - strlen(q);
if (end_of_file)
eof = end_of_file;
if (eof)
AC(mvprintw(0, len - (1 + 6), "%s (EOF)", q));
else
AC(mvprintw(0, len - 1, "%s", q));
......@@ -240,7 +241,7 @@ update(int p)
len, len, tp->rec_data));
t = tp->count;
}
if (end_of_file)
if (eof)
continue;
tp->count += (1.0/3.0 - tp->count) / (double)n;
if (tp->count * 10 < t || l > LINES * 10) {
......@@ -252,6 +253,8 @@ update(int p)
}
}
AC(refresh());
if (eof)
quit = 1;
}
static void *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment