]> git.sur5r.net Git - openocd/commit
target: fix timer callbacks processing
authorPaul Fertser <fercerpav@gmail.com>
Wed, 11 Feb 2015 07:51:17 +0000 (10:51 +0300)
committerPaul Fertser <fercerpav@gmail.com>
Mon, 9 Mar 2015 06:40:04 +0000 (06:40 +0000)
commitb71ae9b1a704a9631698d7d4a92b1dfdfc9a0f69
tree1df6dc27a96322806ce86ac922973aa37e9b99d9
parentca0e237d39a8e50c702cec4d825c4b44d63e4d4a
target: fix timer callbacks processing

Warning, behaviour change: before this patch if a timer callback
returned an error, the other handlers in the list were not called.

This patch fixes two different issues with the way timer callbacks are
called:

1. The function is not designed to be reentrant but a nested call is
possible via: target_handle timer event -> poll -> target events
before/after reexaminantion -> script_command_run ->
target_call_timer_callbacks_now . This patch makes function a no-op
when called recursively;

2. The current code can deal with the case when calling a handler
leads to its removal but not when it leads to removal of the next
callback in the list. This patch defers actual removal to consolidate
it with the calling loop.

These bugs were exposed by Valgrind.

Change-Id: Ia628a744634f5d2911eb329747e826cb9772e789
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2541
Tested-by: jenkins
Reviewed-by: Stian Skjelstad <stian@nixia.no>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/target/target.c
src/target/target.h