Commit 86039424 authored by Cedric Roux's avatar Cedric Roux

T: bugfix: lock required

When the user clicks on "next UE" or "prev UE" we change the
filters of loggers.

At the same time, the main thread of enb.c processes events
received from the soft-modem and uses the filters, some of them
maybe in the process of being changed.

Changing the filters is not atomic and has to be protected.
parent ee934102
...@@ -190,8 +190,12 @@ static void click(void *private, gui *g, ...@@ -190,8 +190,12 @@ static void click(void *private, gui *g,
if (w == e->prev_ue_button) { ue--; if (ue < 0) ue = 0; } if (w == e->prev_ue_button) { ue--; if (ue < 0) ue = 0; }
if (w == e->next_ue_button) ue++; if (w == e->next_ue_button) ue++;
if (ue != ed->ue) set_current_ue(g, ed, ue); if (pthread_mutex_lock(&ed->lock)) abort();
ed->ue = ue; if (ue != ed->ue) {
set_current_ue(g, ed, ue);
ed->ue = ue;
}
if (pthread_mutex_unlock(&ed->lock)) abort();
} }
static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database, static void enb_main_gui(enb_gui *e, gui *g, event_handler *h, void *database,
...@@ -745,7 +749,9 @@ restart: ...@@ -745,7 +749,9 @@ restart:
event e; event e;
e = get_event(enb_data.socket, v, database); e = get_event(enb_data.socket, v, database);
if (e.type == -1) goto restart; if (e.type == -1) goto restart;
if (pthread_mutex_lock(&enb_data.lock)) abort();
handle_event(h, e); handle_event(h, e);
if (pthread_mutex_unlock(&enb_data.lock)) abort();
} }
return 0; return 0;
......
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