diff options
author | Werner Koch <[email protected]> | 2023-12-12 15:31:30 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2023-12-12 15:31:30 +0000 |
commit | f57717bf2314578385e184de5e417b08e22c4c87 (patch) | |
tree | d14f051c2345441c8f2481d3cd4bdc0df144b93b /common/dotlock.c | |
parent | doc: Fix description of scdaemon for --disable-ccid. (diff) | |
download | gnupg-f57717bf2314578385e184de5e417b08e22c4c87.tar.gz gnupg-f57717bf2314578385e184de5e417b08e22c4c87.zip |
common: Improve error return for dotlock.
* common/dotlock.c (dotlock_take_unix): Return a ETIMEDOUT insteaad of
EACCESS on timeout.
(dotlock_take_w32): Ditto.
Diffstat (limited to 'common/dotlock.c')
-rw-r--r-- | common/dotlock.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/common/dotlock.c b/common/dotlock.c index 74186b776..d1058845e 100644 --- a/common/dotlock.c +++ b/common/dotlock.c @@ -1061,6 +1061,7 @@ static int dotlock_take_unix (dotlock_t h, long timeout) { int wtime = 0; + int timedout = 0; int sumtime = 0; int pid; int lastpid = -1; @@ -1218,6 +1219,8 @@ dotlock_take_unix (dotlock_t h, long timeout) wtime = 0; /* Reset because owner chnaged. */ wtimereal = next_wait_interval (&wtime, &timeout); + if (!timeout) + timedout = 1; /* remember. */ sumtime += wtimereal; if (sumtime >= 1500) @@ -1233,7 +1236,7 @@ dotlock_take_unix (dotlock_t h, long timeout) goto again; } - my_set_errno (EACCES); + my_set_errno (timedout? ETIMEDOUT : EACCES); return -1; } #endif /*HAVE_POSIX_SYSTEM*/ @@ -1246,6 +1249,7 @@ static int dotlock_take_w32 (dotlock_t h, long timeout) { int wtime = 0; + int timedout = 0; int w32err; OVERLAPPED ovl; @@ -1273,6 +1277,8 @@ dotlock_take_w32 (dotlock_t h, long timeout) int wtimereal; wtimereal = next_wait_interval (&wtime, &timeout); + if (!timeout) + timedout = 1; /* remember. */ if (wtime >= 800) my_info_1 (_("waiting for lock %s...\n"), h->lockname); @@ -1281,7 +1287,7 @@ dotlock_take_w32 (dotlock_t h, long timeout) goto again; } - my_set_errno (EACCES); + my_set_errno (timedout? ETIMEDOUT : EACCES); return -1; } #endif /*HAVE_DOSISH_SYSTEM*/ |