server/server: fix target timer timing

The change 6363: Call poll at a fixed interval
switched from target_call_timer_callbacks() to target_call_timer_callbacks_now().
It breaks the timing as all timers callbacks are called every time
one timer expires.

Revert this part of change and use target_call_timer_callbacks().

Fixes: db16b3dc5b (Call poll at a fixed interval.)
Change-Id: Ib5b7774de9694d40c55d2a4109d0d1582fc5008b
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7118
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tomas Vanek 2022-08-15 19:18:18 +02:00 committed by Antonio Borneo
parent 386155419b
commit 63cc08f6a2
1 changed files with 7 additions and 4 deletions

View File

@ -473,7 +473,7 @@ int server_loop(struct command_context *command_context)
tv.tv_usec = 0;
retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv);
} else {
/* Every 100ms, can be changed with "poll_period" command */
/* Timeout socket_select() when a target timer expires or every polling_period */
int timeout_ms = next_event - timeval_ms();
if (timeout_ms < 0)
timeout_ms = 0;
@ -507,9 +507,12 @@ int server_loop(struct command_context *command_context)
}
if (retval == 0) {
/* We only execute these callbacks when there was nothing to do or we timed
*out */
target_call_timer_callbacks_now();
/* Execute callbacks of expired timers when
* - there was nothing to do if poll_ok was true
* - socket_select() timed out if poll_ok was false, now one or more
* timers expired or the polling period elapsed
*/
target_call_timer_callbacks();
next_event = target_timer_next_event();
process_jim_events(command_context);