diff options
author | José Bollo <jose.bollo@iot.bzh> | 2019-05-28 09:37:11 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2019-05-29 08:58:56 +0000 |
commit | f9c743046f94769c25ffc5bfd8d190c53cc4d613 (patch) | |
tree | 1a1acec49d5638a1e33e2ba0484b3465f6dd3de2 | |
parent | 02fe255525d3805350676445b5c8854afa46cbe4 (diff) |
jobs: Fix infinite wait lock
The binder was sometime locked until an external
event comes. This was discovered during stressing
startup test that don't expect external inputs and
that then waits for always without terminating.
The issue came from a little hole in the management
of the state of evmgr object. By design the evmgr
has to be synchronised against concurrent accesses
not by itself but by the integration. However, the
state of "running" wasn't set in the code protected
against concurent accesses. The new function allows
the integrator to correctly set the state before
releasing protection.
Bug-AGL: SPEC-2459
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Change-Id: Id75fd97c06d69666ced912a0a61380573dab31af
-rw-r--r-- | src/evmgr.c | 8 | ||||
-rw-r--r-- | src/evmgr.h | 1 | ||||
-rw-r--r-- | src/jobs.c | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/evmgr.c b/src/evmgr.c index 557a9f3a..744d08ba 100644 --- a/src/evmgr.c +++ b/src/evmgr.c @@ -48,6 +48,14 @@ struct evmgr #define EVLOOP_STATE_RUN 2U /** + * prepare the evmgr to run + */ +void evmgr_prepare_run(struct evmgr *evmgr) +{ + evmgr->state = EVLOOP_STATE_WAIT|EVLOOP_STATE_RUN; +} + +/** * Run the event loop is set. */ void evmgr_run(struct evmgr *evmgr) diff --git a/src/evmgr.h b/src/evmgr.h index c78ea33f..2dde16b3 100644 --- a/src/evmgr.h +++ b/src/evmgr.h @@ -20,6 +20,7 @@ struct evmgr; +extern void evmgr_prepare_run(struct evmgr *evmgr); extern void evmgr_run(struct evmgr *evmgr); extern void evmgr_job_run(int signum, struct evmgr *evmgr); extern int evmgr_can_run(struct evmgr *evmgr); @@ -389,6 +389,7 @@ static void thread_run_internal(volatile struct thread *me) abort(); } /* run the events */ + evmgr_prepare_run(evmgr); pthread_mutex_unlock(&mutex); sig_monitor(0, (void(*)(int,void*))evmgr_job_run, evmgr); pthread_mutex_lock(&mutex); |