break from long loops on shutdown request
In loops that typically take longer time to complete, check if there is a pending shutdown request. If so, terminate the loop. This allows to respond to a signal requesting a shutdown during some loops which do not return control to main OpenOCD loop. Change-Id: Iace0b58eddde1237832d0f9333a7c7b930565674 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8032 Reviewed-by: Jan Matyas <jan.matyas@codasip.com> Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
committed by
Antonio Borneo
parent
e8e09b1b55
commit
2e920a212f
@@ -1204,6 +1204,10 @@ int target_run_read_async_algorithm(struct target *target,
|
||||
/* Avoid GDB timeouts */
|
||||
keep_alive();
|
||||
|
||||
if (openocd_is_shutdown_pending()) {
|
||||
retval = ERROR_SERVER_INTERRUPTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (retval != ERROR_OK) {
|
||||
@@ -3224,8 +3228,11 @@ int target_wait_state(struct target *target, enum target_state state, unsigned i
|
||||
nvp_value2name(nvp_target_state, state)->name);
|
||||
}
|
||||
|
||||
if (cur-then > 500)
|
||||
if (cur - then > 500) {
|
||||
keep_alive();
|
||||
if (openocd_is_shutdown_pending())
|
||||
return ERROR_SERVER_INTERRUPTED;
|
||||
}
|
||||
|
||||
if ((cur-then) > ms) {
|
||||
LOG_ERROR("timed out while waiting for target %s",
|
||||
@@ -3507,6 +3514,11 @@ static int target_fill_mem(struct target *target,
|
||||
break;
|
||||
/* avoid GDB timeouts */
|
||||
keep_alive();
|
||||
|
||||
if (openocd_is_shutdown_pending()) {
|
||||
retval = ERROR_SERVER_INTERRUPTED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(target_buf);
|
||||
|
||||
@@ -3849,6 +3861,12 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
|
||||
}
|
||||
}
|
||||
keep_alive();
|
||||
if (openocd_is_shutdown_pending()) {
|
||||
retval = ERROR_SERVER_INTERRUPTED;
|
||||
free(data);
|
||||
free(buffer);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
|
||||
Reference in New Issue
Block a user