mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-09 09:40:45 -04:00
1733. [bug] Return non-zero exit status on initial load failure.
[RT #12658]
This commit is contained in:
parent
74c34ec4a0
commit
bafe87e278
6 changed files with 60 additions and 13 deletions
3
CHANGES
3
CHANGES
|
|
@ -1,6 +1,9 @@
|
|||
1734. [cleanup] 'rndc-confgen -a -t' remove extra '/' in path.
|
||||
[RT #12588]
|
||||
|
||||
1733. [bug] Return non-zero exit status on initial load failure.
|
||||
[RT #12658]
|
||||
|
||||
1726. [port] aix5: add support for aix5.
|
||||
|
||||
1723. [cleanup] Silence compiler warnings from t_tasks.c. [RT #12493]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: server.c,v 1.419.18.9 2004/06/18 04:39:39 marka Exp $ */
|
||||
/* $Id: server.c,v 1.419.18.10 2004/09/29 06:43:53 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -2805,7 +2805,7 @@ run_server(isc_task_t *task, isc_event_t *event) {
|
|||
isc_result_t result;
|
||||
ns_server_t *server = (ns_server_t *)event->ev_arg;
|
||||
|
||||
UNUSED(task);
|
||||
INSIST(task == server->task);
|
||||
|
||||
isc_event_free(&event);
|
||||
|
||||
|
|
@ -2843,11 +2843,11 @@ run_server(isc_task_t *task, isc_event_t *event) {
|
|||
|
||||
isc_hash_init();
|
||||
|
||||
CHECKFATAL(load_zones(server, ISC_FALSE),
|
||||
"loading zones");
|
||||
CHECKFATAL(load_zones(server, ISC_FALSE), "loading zones");
|
||||
|
||||
ns_os_started();
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
|
||||
ISC_LOG_INFO, "running");
|
||||
ISC_LOG_NOTICE, "running");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -3187,8 +3187,7 @@ loadconfig(ns_server_t *server) {
|
|||
start_reserved_dispatches(server);
|
||||
result = load_configuration(ns_g_lwresdonly ?
|
||||
lwresd_g_conffile : ns_g_conffile,
|
||||
server,
|
||||
ISC_FALSE);
|
||||
server, ISC_FALSE);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
end_reserved_dispatches(server, ISC_FALSE);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.h,v 1.22 2004/03/05 04:58:05 marka Exp $ */
|
||||
/* $Id: os.h,v 1.22.18.1 2004/09/29 06:43:54 marka Exp $ */
|
||||
|
||||
#ifndef NS_OS_H
|
||||
#define NS_OS_H 1
|
||||
|
|
@ -61,4 +61,7 @@ ns_os_shutdownmsg(char *command, isc_buffer_t *text);
|
|||
void
|
||||
ns_os_tzset(void);
|
||||
|
||||
void
|
||||
ns_os_started(void);
|
||||
|
||||
#endif /* NS_OS_H */
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.c,v 1.66.18.3 2004/09/16 02:49:50 marka Exp $ */
|
||||
/* $Id: os.c,v 1.66.18.4 2004/09/29 06:43:53 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdarg.h>
|
||||
|
|
@ -104,6 +104,7 @@ static pid_t mainpid = 0;
|
|||
|
||||
static struct passwd *runas_pw = NULL;
|
||||
static isc_boolean_t done_setuid = ISC_FALSE;
|
||||
static int dfd[2] = { -1, -1 };
|
||||
|
||||
#ifdef HAVE_LINUX_CAPABILITY_H
|
||||
|
||||
|
|
@ -305,13 +306,33 @@ ns_os_daemonize(void) {
|
|||
pid_t pid;
|
||||
char strbuf[ISC_STRERRORSIZE];
|
||||
|
||||
if (pipe(dfd) == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
ns_main_earlyfatal("pipe(): %s", strbuf);
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
isc__strerror(errno, strbuf, sizeof(strbuf));
|
||||
ns_main_earlyfatal("fork(): %s", strbuf);
|
||||
}
|
||||
if (pid != 0)
|
||||
_exit(0);
|
||||
if (pid != 0) {
|
||||
int n;
|
||||
/*
|
||||
* Wait for the child to finish loading for the first time.
|
||||
* This would be so much simpler if fork() worked once we
|
||||
* were multi-threaded.
|
||||
*/
|
||||
(void)close(dfd[1]);
|
||||
do {
|
||||
char buf;
|
||||
n = read(dfd[0], &buf, 1);
|
||||
if (n == 1)
|
||||
_exit(0);
|
||||
} while (n == -1 && errno == EINTR);
|
||||
_exit(1);
|
||||
}
|
||||
(void)close(dfd[0]);
|
||||
|
||||
/*
|
||||
* We're the child.
|
||||
|
|
@ -352,6 +373,20 @@ ns_os_daemonize(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ns_os_started(void) {
|
||||
char buf = 0;
|
||||
|
||||
/*
|
||||
* Signal to the parent that we stated successfully.
|
||||
*/
|
||||
if (dfd[0] != -1 && dfd[1] != -1) {
|
||||
write(dfd[1], &buf, 1);
|
||||
close(dfd[1]);
|
||||
dfd[0] = dfd[1] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ns_os_opendevnull(void) {
|
||||
devnullfd = open("/dev/null", O_RDWR, 0);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.h,v 1.9 2004/03/05 04:58:11 marka Exp $ */
|
||||
/* $Id: os.h,v 1.9.18.1 2004/09/29 06:43:54 marka Exp $ */
|
||||
|
||||
#ifndef NS_OS_H
|
||||
#define NS_OS_H 1
|
||||
|
|
@ -61,4 +61,7 @@ ns_os_shutdownmsg(char *command, isc_buffer_t *text);
|
|||
void
|
||||
ns_os_tzset(void);
|
||||
|
||||
void
|
||||
ns_os_started(void);
|
||||
|
||||
#endif /* NS_OS_H */
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.c,v 1.20 2004/03/05 04:58:08 marka Exp $ */
|
||||
/* $Id: os.c,v 1.20.18.1 2004/09/29 06:43:54 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdarg.h>
|
||||
|
|
@ -255,6 +255,10 @@ ns_os_writepidfile(const char *filename, isc_boolean_t first_time) {
|
|||
(void)fclose(lockfile);
|
||||
}
|
||||
|
||||
void
|
||||
ns_os_started(void) {
|
||||
}
|
||||
|
||||
void
|
||||
ns_os_shutdown(void) {
|
||||
closelog();
|
||||
|
|
|
|||
Loading…
Reference in a new issue