[master] d55093f67 Move two time consuming curses operations out of the mutex

Poul-Henning Kamp phk at FreeBSD.org
Mon Dec 11 13:35:08 UTC 2023


commit d55093f671b58b8a2f9dddd7a2aef15ac2895f27
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Dec 11 12:37:57 2023 +0000

    Move two time consuming curses operations out of the mutex

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index ddec07a11..fa26a5ca8 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -151,8 +151,6 @@ update(void)
 	int i, j;
 	unsigned k, l;
 
-	AC(erase());
-
 	/* Draw horizontal axis */
 	for (k = 0; k < n; ++k)
 		(void)mvaddch(LINES - 2, k, '-');
@@ -202,8 +200,6 @@ update(void)
 		for (; l < (bm[k] + bh[k]) / scale; ++l)
 			(void)mvaddch((LINES - 3) - l, k, '|');
 	}
-
-	AC(refresh());
 }
 
 inline static void
@@ -382,9 +378,12 @@ do_curses(void *arg)
 	AC(curs_set(0));
 	AC(erase());
 	while (!VSIG_int && !VSIG_term && !VSIG_hup) {
+
+		AC(erase());
 		PTOK(pthread_mutex_lock(&mtx));
 		update();
 		PTOK(pthread_mutex_unlock(&mtx));
+		AC(refresh());
 
 		assert(ms_delay > 0);
 		timeout(ms_delay);


More information about the varnish-commit mailing list