diff --git a/common/utils/T/tracer/gui/gui.c b/common/utils/T/tracer/gui/gui.c index 2166774d929f441595ca06d6fa080a2980324c12..ef8640b0def445e5cc4d29f13965d981f3bd3dd3 100644 --- a/common/utils/T/tracer/gui/gui.c +++ b/common/utils/T/tracer/gui/gui.c @@ -9,18 +9,24 @@ void glock(gui *_gui) { struct gui *g = _gui; if (pthread_mutex_lock(g->lock)) ERR("mutex error\n"); - xlock(g->x); } void gunlock(gui *_gui) { struct gui *g = _gui; - xunlock(g->x); if (pthread_mutex_unlock(g->lock)) ERR("mutex error\n"); } int new_color(gui *_gui, char *color) { struct gui *g = _gui; - return x_new_color(g->x, color); + int ret; + + glock(g); + + ret = x_new_color(g->x, color); + + gunlock(g); + + return ret; } diff --git a/common/utils/T/tracer/gui/init.c b/common/utils/T/tracer/gui/init.c index 445f696643c0eba3c4ef6ac18e72fa26cb8889dd..c6d5e3e435366b574b3495ee41b9c6df45621744 100644 --- a/common/utils/T/tracer/gui/init.c +++ b/common/utils/T/tracer/gui/init.c @@ -12,8 +12,6 @@ gui *gui_init(void) { struct gui *ret; - x_init_threading(); - ret = calloc(1, sizeof(struct gui)); if (ret == NULL) OOM; @@ -25,7 +23,12 @@ gui *gui_init(void) if (pipe(ret->event_pipe)) ERR("%s\n", strerror(errno)); + /* lock not necessary but there for consistency (when instrumenting x.c + * we need the gui to be locked when calling any function in x.c) + */ + glock(ret); ret->x = x_open(); + gunlock(ret); return ret; } diff --git a/common/utils/T/tracer/gui/loop.c b/common/utils/T/tracer/gui/loop.c index 94b7fe54bd5f1cc436f8d05ebc7f6e51f639c464..8ceb3c06e1c4936dc508fea8e1ce8dc33b0d99c3 100644 --- a/common/utils/T/tracer/gui/loop.c +++ b/common/utils/T/tracer/gui/loop.c @@ -16,14 +16,21 @@ void gui_loop(gui *_gui) int maxfd; fd_set rd; + /* lock not necessary but there for consistency (when instrumenting x.c + * we need the gui to be locked when calling any function in x.c) + */ + glock(g); xfd = x_connection_fd(g->x); + gunlock(g); eventfd = g->event_pipe[0]; if (eventfd > xfd) maxfd = eventfd; else maxfd = xfd; while (1) { + glock(g); x_flush(g->x); + gunlock(g); FD_ZERO(&rd); FD_SET(xfd, &rd); FD_SET(eventfd, &rd); diff --git a/common/utils/T/tracer/gui/x.c b/common/utils/T/tracer/gui/x.c index 12888da468986fa52c292d9626c09799c97bff1f..50164dce359a570a2df901b5e1c3dac46bb8dae6 100644 --- a/common/utils/T/tracer/gui/x.c +++ b/common/utils/T/tracer/gui/x.c @@ -6,23 +6,6 @@ #include <stdlib.h> #include <string.h> -void x_init_threading(void) -{ - if (XInitThreads() == False) abort(); -} - -void xlock(x_connection *_x) -{ - struct x_connection *x = _x; - XLockDisplay(x->d); -} - -void xunlock(x_connection *_x) -{ - struct x_connection *x = _x; - XUnlockDisplay(x->d); -} - int x_connection_fd(x_connection *_x) { struct x_connection *x = _x; diff --git a/common/utils/T/tracer/gui/x.h b/common/utils/T/tracer/gui/x.h index 82e46cac9da477c0159de80903877e87c21af7c6..c1f8d33d89e8831c8a1882ecbf737763c02191fb 100644 --- a/common/utils/T/tracer/gui/x.h +++ b/common/utils/T/tracer/gui/x.h @@ -6,11 +6,6 @@ typedef void x_connection; typedef void x_window; -void x_init_threading(void); - -void xlock(x_connection *x); -void xunlock(x_connection *x); - x_connection *x_open(void); x_window *x_create_window(x_connection *x, int width, int height,