diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-11-23 09:59:06 +0100 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-11-23 11:12:08 +0100 |
commit | a80f8dcf2c6eb3b54658218bc081ee9694204dd5 (patch) | |
tree | 8342b730def57d7b33bd99d661a087dfe1f715b5 /src/wins.c | |
parent | e16ac0a8a8c18c831e95e1a0799e919e61f5da48 (diff) | |
download | calcurse-a80f8dcf2c6eb3b54658218bc081ee9694204dd5.zip |
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 <calcurse@cryptocrack.de>
Diffstat (limited to 'src/wins.c')
-rw-r--r-- | src/wins.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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) |