Commit d1dd5265 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Use VUT.name as descriptive name of VSM context.

Fixes issue where a 2nd VSM context is used to get the current name,
not taking any -n/-N arguments into account
parent f09b51fb
...@@ -182,7 +182,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], ...@@ -182,7 +182,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[],
} }
static void static void
update(const struct VSM_data *vd, int p) update(int p)
{ {
struct top *tp, *tp2; struct top *tp, *tp2;
int l, len; int l, len;
...@@ -200,7 +200,7 @@ update(const struct VSM_data *vd, int p) ...@@ -200,7 +200,7 @@ update(const struct VSM_data *vd, int p)
if (n < p) if (n < p)
n++; n++;
AC(erase()); AC(erase());
AC(mvprintw(0, 0, "%*s", COLS - 1, VSM_Name(vd))); AC(mvprintw(0, 0, "%*s", COLS - 1, VUT.name));
AC(mvprintw(0, 0, "list length %u", ntop)); AC(mvprintw(0, 0, "list length %u", ntop));
for (tp = VRB_MIN(top_tree, &top_tree_head); tp != NULL; tp = tp2) { for (tp = VRB_MIN(top_tree, &top_tree_head); tp != NULL; tp = tp2) {
tp2 = VRB_NEXT(top_tree, &top_tree_head, tp); tp2 = VRB_NEXT(top_tree, &top_tree_head, tp);
...@@ -231,8 +231,8 @@ static void * ...@@ -231,8 +231,8 @@ static void *
do_curses(void *arg) do_curses(void *arg)
{ {
int i; int i;
struct VSM_data *vd = (struct VSM_data *)arg;
(void)arg;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
if (VSL_tags[i] == NULL) if (VSL_tags[i] == NULL)
continue; continue;
...@@ -249,7 +249,7 @@ do_curses(void *arg) ...@@ -249,7 +249,7 @@ do_curses(void *arg)
AC(erase()); AC(erase());
for (;;) { for (;;) {
AZ(pthread_mutex_lock(&mtx)); AZ(pthread_mutex_lock(&mtx));
update(vd, period); update(period);
AZ(pthread_mutex_unlock(&mtx)); AZ(pthread_mutex_unlock(&mtx));
timeout(1000); timeout(1000);
...@@ -315,11 +315,9 @@ usage(int status) ...@@ -315,11 +315,9 @@ usage(int status)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
struct VSM_data *vd;
int o, once = 0; int o, once = 0;
pthread_t thr; pthread_t thr;
vd = VSM_New();
VUT_Init(progname); VUT_Init(progname);
while ((o = getopt(argc, argv, vopt_optstring)) != -1) { while ((o = getopt(argc, argv, vopt_optstring)) != -1) {
...@@ -349,20 +347,21 @@ main(int argc, char **argv) ...@@ -349,20 +347,21 @@ main(int argc, char **argv)
} }
} }
VUT.dispatch_f = &accumulate; VUT_Setup();
VUT.dispatch_priv = NULL; if (!once) {
if (!once){ if (pthread_create(&thr, NULL, do_curses, NULL) != 0) {
if (pthread_create(&thr, NULL, do_curses, vd) != 0) { fprintf(stderr, "pthread_create(): %s\n",
fprintf(stderr, "pthread_create(): %s\n", strerror(errno)); strerror(errno));
exit(1); exit(1);
} }
} }
VUT_Setup(); VUT.dispatch_f = &accumulate;
VUT.dispatch_priv = NULL;
VUT_Main(); VUT_Main();
VUT_Fini();
if (once) if (once)
dump(); dump();
else else
pthread_join(thr, NULL); pthread_join(thr, NULL);
VUT_Fini();
exit(0); exit(0);
} }
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