Skip to contentSkip to conversation

perf tui: Make ui__warning modal

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Mar 2, 2011 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  a1ceb741cf86ef433006379742db81c00b450bae
Gitweb:     http://git.kernel.org/tip/a1ceb741cf86ef433006379742db81c00b450bae
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Tue, 1 Mar 2011 10:24:43 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 1 Mar 2011 10:24:43 -0300

perf tui: Make ui__warning modal

By taking the ui__lock so that no other screen updates take place while waiting for the user.

That was happening when handling an invalid --vmlinux parameter in 'perf top --tui', with the screen refresh routine repainting the screen and removing the warning window.

Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Tom Zanussi <[email protected]>
LKML-Reference: <new-submission>

---
 tools/perf/util/ui/util.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/ui/util.c +5 -2
index 7b5a892..fdf1fc8 100644
@@ -9,6 +9,7 @@
 #include "../debug.h"
 #include "browser.h"
 #include "helpline.h"
+#include "ui.h"
 #include "util.h"
 
 static void newt_form__set_exit_keys(newtComponent self)
@@ -118,10 +119,12 @@ void ui__warning(const char *format, ...)
 	va_list args;
 
 	va_start(args, format);
-	if (use_browser > 0)
+	if (use_browser > 0) {
+		pthread_mutex_lock(&ui__lock);
 		newtWinMessagev((char *)warning_str, (char *)ok,
 				(char *)format, args);
-	else
+		pthread_mutex_unlock(&ui__lock);
+	} else
 		vfprintf(stderr, format, args);
 	va_end(args);
 }