Use nanosleep for log verify retry delay
This commit is contained in:
parent
d0e53170f3
commit
8b2979e11d
|
|
@ -8,7 +8,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <time.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
AMDUAT_ASL_LOG_MAGIC_LEN = 8,
|
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;
|
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) {
|
void amduat_asl_log_chunk_free(amduat_asl_log_chunk_t *chunk) {
|
||||||
if (chunk == NULL) {
|
if (chunk == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -672,7 +679,7 @@ amduat_asl_store_error_t amduat_asl_log_append(
|
||||||
verify_attempt + 1u >= AMDUAT_ASL_LOG_VERIFY_MAX_RETRIES) {
|
verify_attempt + 1u >= AMDUAT_ASL_LOG_VERIFY_MAX_RETRIES) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(AMDUAT_ASL_LOG_VERIFY_RETRY_US);
|
amduat_asl_log_retry_sleep_us(AMDUAT_ASL_LOG_VERIFY_RETRY_US);
|
||||||
verify_attempt++;
|
verify_attempt++;
|
||||||
}
|
}
|
||||||
if (verify_err != AMDUAT_ASL_STORE_OK) {
|
if (verify_err != AMDUAT_ASL_STORE_OK) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue