Skip to content
  • Paul Fertser's avatar
    target: fix timer callbacks processing · b71ae9b1
    Paul Fertser authored
    
    
    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: default avatarPaul Fertser <fercerpav@gmail.com>
    Reviewed-on: http://openocd.zylin.com/2541
    
    
    Tested-by: jenkins
    Reviewed-by: default avatarStian Skjelstad <stian@nixia.no>
    Reviewed-by: default avatarAndreas Färber <afaerber@suse.de>
    Reviewed-by: default avatarSpencer Oliver <spen@spen-soft.co.uk>
    b71ae9b1