Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/3] Factorize the code that unlock the fcntl() lock into funlockhistfile().
---
Src/hist.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/Src/hist.c b/Src/hist.c
index 4e1f24afe..981316674 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -2571,6 +2571,15 @@ flockhistfile(char *fn, int keep_trying)
return 0;
}
+
+static void
+funlockhistfile()
+{
+ if (flock_fd >= 0) {
+ close(flock_fd);
+ flock_fd = -1;
+ }
+}
#endif
/**/
@@ -2951,10 +2960,7 @@ savehistfile(char *fn, int err, int writeflags)
} else {
/* We renamed over the locked HISTFILE, so close fd.
* If we do more writing, we'll get a lock then. */
- if (flock_fd >= 0) {
- close(flock_fd);
- flock_fd = -1;
- }
+ funlockhistfile();
#endif
}
}
@@ -3158,10 +3164,7 @@ lockhistfile(char *fn, int keep_trying)
if (ct == lockhistct) {
#ifdef HAVE_FCNTL_H
- if (flock_fd >= 0) {
- close(flock_fd);
- flock_fd = -1;
- }
+ funlockhistfile();
#endif
DPUTS(ret == 0, "BUG: return value non-zero on locking error");
return ret;
@@ -3191,10 +3194,7 @@ unlockhistfile(char *fn)
unlink(lockfile);
free(lockfile);
#ifdef HAVE_FCNTL_H
- if (flock_fd >= 0) {
- close(flock_fd);
- flock_fd = -1;
- }
+ funlockhistfile();
#endif
}
}
--
2.20.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author