summaryrefslogtreecommitdiff
path: root/src/wins.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-11-23 09:59:06 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-11-23 11:12:08 +0100
commita80f8dcf2c6eb3b54658218bc081ee9694204dd5 (patch)
tree8342b730def57d7b33bd99d661a087dfe1f715b5 /src/wins.c
parente16ac0a8a8c18c831e95e1a0799e919e61f5da48 (diff)
downloadcalcurse-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.c28
1 files changed, 28 insertions, 0 deletions
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)