This is an automated email from Gerrit. "Evgeniy Naydanov <evgeniy.nayda...@syntacore.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8118
-- gerrit commit 6d737048482b4b6fe0ed1475f184529d90eb2aeb Author: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com> Date: Fri Jan 26 12:19:02 2024 +0300 Revert "break from long loops on shutdown request" This reverts commit 2e920a212fbe2de705811d547c169c1ae1611a02. The reason is, after `openocd_is_shutdown_pending()` becomes true, arbitrary command may be executed: * In `target_destroy()` and the corresponding `target->type->deinit_target()`. * In user-specifyed `pre_shutdown_commands` list. Change-Id: I3f1c2c8ecbf9df4c88f775f4bd203fe3ea7d2121 Signed-off-by: Evgeniy Naydanov <evgeniy.nayda...@syntacore.com> diff --git a/src/server/server.h b/src/server/server.h index ea1e94ec5f..c9d4698af8 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -118,6 +118,5 @@ COMMAND_HELPER(server_port_command, unsigned short *out); #define ERROR_SERVER_REMOTE_CLOSED (-400) #define ERROR_CONNECTION_REJECTED (-401) -#define ERROR_SERVER_INTERRUPTED (-402) #endif /* OPENOCD_SERVER_SERVER_H */ diff --git a/src/target/image.c b/src/target/image.c index 440fe17d18..9175c200af 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -24,7 +24,6 @@ #include "image.h" #include "target.h" #include <helper/log.h> -#include <server/server.h> /* convert ELF header field to host endianness */ #define field16(elf, field) \ @@ -1296,8 +1295,6 @@ int image_calculate_checksum(const uint8_t *buffer, uint32_t nbytes, uint32_t *c crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buffer++) & 255]; } keep_alive(); - if (openocd_is_shutdown_pending()) - return ERROR_SERVER_INTERRUPTED; } LOG_DEBUG("Calculating checksum done; checksum=0x%" PRIx32, crc); diff --git a/src/target/target.c b/src/target/target.c index 920511e963..d9638ef43d 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1200,10 +1200,6 @@ 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,11 +3220,8 @@ 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", @@ -3510,11 +3503,6 @@ 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); @@ -3857,12 +3845,6 @@ 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); --