Commit 2c329da8 authored by Mark Andrews's avatar Mark Andrews
Browse files

1733. [bug] Return non-zero exit status on initial load failure.

                        [RT #12658]
parent c42ab597
1734. [cleanup] 'rndc-confgen -a -t' remove extra '/' in path.
[RT #12588]
1733. [placeholder] rt12658
1733. [bug] Return non-zero exit status on initial load failure.
[RT #12658]
1732. [placeholder] rt12467
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.428 2004/06/18 04:38:45 marka Exp $ */
/* $Id: server.c,v 1.429 2004/09/29 06:45:37 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.23 2004/09/29 06:45:37 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.69 2004/09/16 02:49:41 marka Exp $ */
/* $Id: os.c,v 1.70 2004/09/29 06:45:37 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.10 2004/09/29 06:45:38 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.21 2004/09/29 06:45:38 marka Exp $ */
#include <config.h>
#include <stdarg.h>
......@@ -282,3 +282,7 @@ ns_os_tzset(void) {
tzset();
#endif
}
void
ns_os_started(void) {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment