Skip to content

Commit

Permalink
core: ubx_block_start: set block state active before running start
Browse files Browse the repository at this point in the history
This avoids a race condition in which a high priority pthread preempts
the called of block_start before it could set the new block state. In
that case it remains in inactive until the called runs again. In the
case of autostop_steps this causes problems due to ubx_block_stop
failing because the ptrig block is still in inactive.

Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed May 11, 2020
1 parent 0c91aed commit 11f3d66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libubx/ubx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2233,17 +2233,20 @@ int ubx_block_start(ubx_block_t *b)
if (ret < 0)
goto out;

b->block_state = BLOCK_STATE_ACTIVE;

if (b->start == NULL)
goto out_ok;

ret = b->start(b);

if (ret != 0) {
b->block_state = BLOCK_STATE_INACTIVE;
ubx_err(b, "start failed");
goto out;
}

out_ok:
b->block_state = BLOCK_STATE_ACTIVE;
ret = 0;

out:
Expand Down

0 comments on commit 11f3d66

Please sign in to comment.