Commit 6ffa65f1 authored by Cedric Roux's avatar Cedric Roux
Browse files

get rid of X locks, there were missing glock/gunlock here and there

parent 9463903d
......@@ -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;
}
......@@ -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;
}
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
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