diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-18 04:44:36 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-18 04:44:36 +0000 |
| commit | 8d467ecea99eb42dab3f6a8dcd888e8e623e2680 (patch) | |
| tree | 748be20597ee549862ade30ee89f9844ab6a5538 | |
| parent | 3f2a6e749f63d3c0a8e8864081f64f6111698839 (diff) | |
util/nvmutil: limit EAGAIN/EINTR retries
set it really high though, so it's still
basically reliably
an EINTR/EAGAIN storm could cause problems
in prw()
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 11 | ||||
| -rw-r--r-- | util/nvmutil/nvmutil.h | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 5becd165..34b6f38b 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -2261,6 +2261,12 @@ prw(int fd, void *mem, unsigned long nrw, int loop_eagain, int loop_eintr, int off_reset) { +#ifndef MAX_EAGAIN_RETRIES + unsigned long retries = 100000; +#else + unsigned long retries = MAX_EAGAIN_RETRIES; +#endif + long r; int positional_rw; struct stat st; @@ -2388,8 +2394,9 @@ real_pread_pwrite: } } while (r == -1 && - (errno == try_err(loop_eintr, EINTR) - || errno == try_err(loop_eagain, EAGAIN))); + (errno == try_err(loop_eintr, EINTR) || + errno == try_err(loop_eagain, EAGAIN)) && + retries++ < MAX_EAGAIN_RETRIES); } saved_errno = errno; diff --git a/util/nvmutil/nvmutil.h b/util/nvmutil/nvmutil.h index 57ec6bd6..94ad8f62 100644 --- a/util/nvmutil/nvmutil.h +++ b/util/nvmutil/nvmutil.h @@ -36,6 +36,10 @@ int fchmod(int fd, mode_t mode); #define HAVE_REAL_PREAD_PWRITE 0 #endif +#ifndef MAX_EAGAIN_RETRIES +#define MAX_EAGAIN_RETRIES 100000 +#endif + #ifndef LOOP_EAGAIN #define LOOP_EAGAIN 1 #endif |
