summaryrefslogtreecommitdiffstats
path: root/bin/named/os.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:41:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 16:41:29 +0000
commite2fc8e037ea6bb5de92b25ec9c12a624737ac5ca (patch)
tree65e6bbf5e12c3fe09b43e577f8d1786d06bcd559 /bin/named/os.c
parentReleasing progress-linux version 1:9.18.19-1~deb12u1progress7u1. (diff)
downloadbind9-e2fc8e037ea6bb5de92b25ec9c12a624737ac5ca.tar.xz
bind9-e2fc8e037ea6bb5de92b25ec9c12a624737ac5ca.zip
Merging upstream version 1:9.18.24.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin/named/os.c')
-rw-r--r--bin/named/os.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/bin/named/os.c b/bin/named/os.c
index 7af4729..0222abb 100644
--- a/bin/named/os.c
+++ b/bin/named/os.c
@@ -552,17 +552,19 @@ cleanup_pidfile(void) {
}
static void
-cleanup_lockfile(void) {
+cleanup_lockfile(bool unlink_lockfile) {
if (singletonfd != -1) {
close(singletonfd);
singletonfd = -1;
}
if (lockfile != NULL) {
- int n = unlink(lockfile);
- if (n == -1 && errno != ENOENT) {
- named_main_earlywarning("unlink '%s': failed",
- lockfile);
+ if (unlink_lockfile) {
+ int n = unlink(lockfile);
+ if (n == -1 && errno != ENOENT) {
+ named_main_earlywarning("unlink '%s': failed",
+ lockfile);
+ }
}
free(lockfile);
lockfile = NULL;
@@ -830,7 +832,7 @@ named_os_issingleton(const char *filename) {
if (ret == -1) {
named_main_earlywarning("couldn't create '%s'",
filename);
- cleanup_lockfile();
+ cleanup_lockfile(false);
return (false);
}
}
@@ -842,7 +844,7 @@ named_os_issingleton(const char *filename) {
singletonfd = open(filename, O_WRONLY | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (singletonfd == -1) {
- cleanup_lockfile();
+ cleanup_lockfile(false);
return (false);
}
@@ -854,8 +856,7 @@ named_os_issingleton(const char *filename) {
/* Non-blocking (does not wait for lock) */
if (fcntl(singletonfd, F_SETLK, &lock) == -1) {
- close(singletonfd);
- singletonfd = -1;
+ cleanup_lockfile(false);
return (false);
}
@@ -866,7 +867,7 @@ void
named_os_shutdown(void) {
closelog();
cleanup_pidfile();
- cleanup_lockfile();
+ cleanup_lockfile(true);
}
void