Use nanosleep for log verify retry delay

This commit is contained in:
Carl Niklas Rydberg 2026-02-08 08:46:34 +01:00
parent d0e53170f3
commit 8b2979e11d

View file

@ -8,7 +8,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
enum {
AMDUAT_ASL_LOG_MAGIC_LEN = 8,
@ -109,6 +109,13 @@ static bool amduat_asl_log_add_size(size_t *acc, size_t add) {
return true;
}
static void amduat_asl_log_retry_sleep_us(uint32_t delay_us) {
struct timespec ts;
ts.tv_sec = (time_t)(delay_us / 1000000u);
ts.tv_nsec = (long)((delay_us % 1000000u) * 1000u);
(void)nanosleep(&ts, NULL);
}
void amduat_asl_log_chunk_free(amduat_asl_log_chunk_t *chunk) {
if (chunk == NULL) {
return;
@ -672,7 +679,7 @@ amduat_asl_store_error_t amduat_asl_log_append(
verify_attempt + 1u >= AMDUAT_ASL_LOG_VERIFY_MAX_RETRIES) {
break;
}
usleep(AMDUAT_ASL_LOG_VERIFY_RETRY_US);
amduat_asl_log_retry_sleep_us(AMDUAT_ASL_LOG_VERIFY_RETRY_US);
verify_attempt++;
}
if (verify_err != AMDUAT_ASL_STORE_OK) {