From a80f8dcf2c6eb3b54658218bc081ee9694204dd5 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 23 Nov 2012 09:59:06 +0100 Subject: Lock screen when drawing on the calendar/notification panel Lock the screen if either the calendar panel or the notification bar is updated to avoid race conditions. Addresses BUG#6. Note that we currently always use a screen-level lock, even if only one window is affected. This is to be changed in the future. Signed-off-by: Lukas Fleischer --- src/wins.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/wins.c') diff --git a/src/wins.c b/src/wins.c index d518377..64dd962 100644 --- a/src/wins.c +++ b/src/wins.c @@ -76,6 +76,32 @@ static void screen_release(void) pthread_mutex_unlock(&screen_mutex); } +/* + * FIXME: The following functions currently lock the whole screen. Use both + * window-level and screen-level mutexes (or use use_screen() and use_window(), + * see curs_threads(3)) to avoid locking too much. + */ + +unsigned wins_nbar_lock(void) +{ + return screen_acquire(); +} + +void wins_nbar_unlock(void) +{ + screen_release(); +} + +unsigned wins_calendar_lock(void) +{ + return screen_acquire(); +} + +void wins_calendar_unlock(void) +{ + screen_release(); +} + int wins_refresh(void) { int rc; @@ -476,10 +502,12 @@ static void border_nocolor(WINDOW * window) void wins_update_border(int flags) { if (flags & FLAG_CAL) { + wins_calendar_lock(); if (slctd_win == CAL) border_color(win[CAL].p); else border_nocolor(win[CAL].p); + wins_calendar_unlock(); } if (flags & FLAG_APP) { if (slctd_win == APP) -- cgit v1.2.3-54-g00ecf