Merge pull request #27843 from yuwata/usleep_safe

time-util: introduce usleep_safe()
This commit is contained in:
Lennart Poettering
2023-06-23 23:03:15 +02:00
committed by GitHub
22 changed files with 80 additions and 60 deletions
+1 -1
View File
@@ -2766,7 +2766,7 @@ static int verity_partition(
try_again:
/* Device is being removed by another process. Let's wait for a while. */
(void) usleep(2 * USEC_PER_MSEC);
(void) usleep_safe(2 * USEC_PER_MSEC);
}
/* All trials failed or a conflicting verity device exists. Let's try to activate with a unique name. */
+3 -3
View File
@@ -203,7 +203,7 @@ static int loop_configure_fallback(int fd, const struct loop_config *c) {
/* Sleep some random time, but at least 10ms, at most 250ms. Increase the delay the more
* failed attempts we see */
(void) usleep(UINT64_C(10) * USEC_PER_MSEC +
(void) usleep_safe(UINT64_C(10) * USEC_PER_MSEC +
random_u64_range(UINT64_C(240) * USEC_PER_MSEC * n_attempts/64));
}
@@ -595,7 +595,7 @@ static int loop_device_make_internal(
usec = random_u64_range(UINT64_C(10) * USEC_PER_MSEC +
UINT64_C(240) * USEC_PER_MSEC * n_attempts/64);
log_debug("Trying again after %s.", FORMAT_TIMESPAN(usec, USEC_PER_MSEC));
(void) usleep(usec);
(void) usleep_safe(usec);
}
d->backing_file = TAKE_PTR(backing_file);
@@ -833,7 +833,7 @@ static LoopDevice* loop_device_free(LoopDevice *d) {
delay *= 2;
}
(void) usleep(delay);
(void) usleep_safe(delay);
}
}