From 4d7440bfcf34853101e59923d3df0cad1b2f5e56 Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Tue, 3 May 2016 16:40:53 +0200 Subject: [PATCH] add more locks in view/textlist.c no deadlock should be possible as of the current state of things. When the textlist's lock is set the GUI lock is never on. Let's cross fingers that things don't change crazily in the future... --- common/utils/T/tracer/view/textlist.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/utils/T/tracer/view/textlist.c b/common/utils/T/tracer/view/textlist.c index e849cb964a..6aec4848d3 100644 --- a/common/utils/T/tracer/view/textlist.c +++ b/common/utils/T/tracer/view/textlist.c @@ -45,7 +45,6 @@ static void *textlist_thread(void *_this) _append(this, s, &deleted); free(s); } - if (pthread_mutex_unlock(&this->lock)) abort(); if (dirty) { text_list_state(this->g, this->w, &visible_lines, &start_line, &number_of_lines); @@ -58,6 +57,7 @@ static void *textlist_thread(void *_this) /* this call is not necessary, but if things change in text_list... */ widget_dirty(this->g, this->w); } + if (pthread_mutex_unlock(&this->lock)) abort(); sleepms(1000/this->refresh_rate); } @@ -90,6 +90,8 @@ static void scroll(void *private, gui *g, int new_line; int inc; + if (pthread_mutex_lock(&this->lock)) abort(); + text_list_state(g, w, &visible_lines, &start_line, &number_of_lines); inc = 10; if (inc > visible_lines - 2) inc = visible_lines - 2; @@ -107,6 +109,8 @@ static void scroll(void *private, gui *g, this->autoscroll = 0; else this->autoscroll = 1; + + if (pthread_mutex_unlock(&this->lock)) abort(); } static void click(void *private, gui *g, @@ -116,7 +120,11 @@ static void click(void *private, gui *g, int *d = notification_data; int button = d[1]; + if (pthread_mutex_lock(&this->lock)) abort(); + if (button == 1) this->autoscroll = 1 - this->autoscroll; + + if (pthread_mutex_unlock(&this->lock)) abort(); } view *new_textlist(int maxsize, float refresh_rate, gui *g, widget *w) -- GitLab