+1277. [bug] Failure to write pid-file should not be fatal on
+ reload. [RT #2861]
+
1276. [contrib] 'queryperf' now has EDNS (-e) + DNSSEC DO (-D) support.
1275. [bug] When verifying that an NXT proves nonexistence, check
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: main.h,v 1.9 2001/09/07 00:36:55 marka Exp $ */
+/* $Id: main.h,v 1.10 2002/05/03 05:28:23 marka Exp $ */
#ifndef NAMED_MAIN_H
#define NAMED_MAIN_H 1
void
ns_main_earlyfatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
+void
+ns_main_earlywarning(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
+
void
ns_main_setmemstats(const char *);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: main.c,v 1.127 2002/03/13 23:36:14 bwelling Exp $ */
+/* $Id: main.c,v 1.128 2002/05/03 05:28:19 marka Exp $ */
#include <config.h>
static char absolute_conffile[ISC_DIR_PATHMAX];
static char saved_command_line[512];
-static void
-ns_main_earlywarning(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
-
-static void
+void
ns_main_earlywarning(const char *format, ...) {
va_list args;
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: server.c,v 1.374 2002/04/26 00:40:24 marka Exp $ */
+/* $Id: server.c,v 1.375 2002/05/03 05:28:21 marka Exp $ */
#include <config.h>
obj = NULL;
if (ns_config_get(maps, "pid-file", &obj) == ISC_R_SUCCESS)
if (cfg_obj_isvoid(obj))
- ns_os_writepidfile(NULL);
+ ns_os_writepidfile(NULL, first_time);
else
- ns_os_writepidfile(cfg_obj_asstring(obj));
+ ns_os_writepidfile(cfg_obj_asstring(obj), first_time);
else if (ns_g_lwresdonly)
- ns_os_writepidfile(lwresd_g_defaultpidfile);
+ ns_os_writepidfile(lwresd_g_defaultpidfile, first_time);
else
- ns_os_writepidfile(ns_g_defaultpidfile);
+ ns_os_writepidfile(ns_g_defaultpidfile, first_time);
obj = NULL;
if (options != NULL &&
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: os.h,v 1.18 2001/12/01 00:34:24 marka Exp $ */
+/* $Id: os.h,v 1.19 2002/05/03 05:28:26 marka Exp $ */
#ifndef NS_OS_H
#define NS_OS_H 1
ns_os_minprivs(void);
void
-ns_os_writepidfile(const char *filename);
+ns_os_writepidfile(const char *filename, isc_boolean_t first_time);
void
ns_os_shutdown(void);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: os.c,v 1.57 2001/12/01 00:34:23 marka Exp $ */
+/* $Id: os.c,v 1.58 2002/05/03 05:28:25 marka Exp $ */
#include <config.h>
#include <stdarg.h>
}
void
-ns_os_writepidfile(const char *filename) {
+ns_os_writepidfile(const char *filename, isc_boolean_t first_time) {
int fd;
FILE *lockfile;
size_t len;
pid_t pid;
char strbuf[ISC_STRERRORSIZE];
+ void (*report)(const char *, ...);
/*
* The caller must ensure any required synchronization.
*/
+ report = first_time ? ns_main_earlyfatal : ns_main_earlywarning;
+
cleanup_pidfile();
if (filename == NULL)
pidfile = malloc(len + 1);
if (pidfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
- ns_main_earlyfatal("couldn't malloc '%s': %s",
- filename, strbuf);
+ (*report)("couldn't malloc '%s': %s", filename, strbuf);
+ return;
}
/* This is safe. */
strcpy(pidfile, filename);
fd = safe_open(filename, ISC_FALSE);
if (fd < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
- ns_main_earlyfatal("couldn't open pid file '%s': %s",
- filename, strbuf);
+ (*report)("couldn't open pid file '%s': %s", filename, strbuf);
+ free(pidfile);
+ pidfile = NULL;
+ return;
}
lockfile = fdopen(fd, "w");
if (lockfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
- ns_main_earlyfatal("could not fdopen() pid file '%s': %s",
- filename, strbuf);
+ (*report)("could not fdopen() pid file '%s': %s",
+ filename, strbuf);
+ (void)close(fd);
+ cleanup_pidfile();
+ return;
}
#ifdef HAVE_LINUXTHREADS
pid = mainpid;
#else
pid = getpid();
#endif
- if (fprintf(lockfile, "%ld\n", (long)pid) < 0)
- ns_main_earlyfatal("fprintf() to pid file '%s' failed",
- filename);
- if (fflush(lockfile) == EOF)
- ns_main_earlyfatal("fflush() to pid file '%s' failed",
- filename);
+ if (fprintf(lockfile, "%ld\n", (long)pid) < 0) {
+ (*report)("fprintf() to pid file '%s' failed", filename);
+ (void)fclose(lockfile);
+ cleanup_pidfile();
+ return;
+ }
+ if (fflush(lockfile) == EOF) {
+ (*report)("fflush() to pid file '%s' failed", filename);
+ (void)fclose(lockfile);
+ cleanup_pidfile();
+ return;
+ }
(void)fclose(lockfile);
}
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: os.h,v 1.5 2001/12/01 00:34:27 marka Exp $ */
+/* $Id: os.h,v 1.6 2002/05/03 05:28:29 marka Exp $ */
#ifndef NS_OS_H
#define NS_OS_H 1
ns_os_minprivs(void);
void
-ns_os_writepidfile(const char *filename);
+ns_os_writepidfile(const char *filename, isc_boolean_t first_time);
void
ns_os_shutdown(void);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: os.c,v 1.13 2001/12/01 00:34:26 marka Exp $ */
+/* $Id: os.c,v 1.14 2002/05/03 05:28:27 marka Exp $ */
#include <config.h>
#include <stdarg.h>
}
void
-ns_os_writepidfile(const char *filename) {
+ns_os_writepidfile(const char *filename, isc_boolean_t first_time) {
int fd;
FILE *lockfile;
size_t len;
pid_t pid;
char strbuf[ISC_STRERRORSIZE];
+ void (*report)(const char *, ...);
/*
* The caller must ensure any required synchronization.
*/
+ report = first_time ? ns_main_earlyfatal : ns_main_earlywarning;
+
cleanup_pidfile();
if (strcmp(filename, "none") == 0)
pidfile = malloc(len + 1);
if (pidfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
- ns_main_earlyfatal("couldn't malloc '%s': %s",
- filename, strbuf);
+ (*report)("couldn't malloc '%s': %s", filename, strbuf);
+ return;
}
/* This is safe. */
strcpy(pidfile, filename);
fd = safe_open(filename, ISC_FALSE);
if (fd < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
- ns_main_earlyfatal("couldn't open pid file '%s': %s",
- filename, strbuf);
+ (*report)("couldn't open pid file '%s': %s", filename, strbuf);
+ free(pidfile);
+ pidfile = NULL;
+ return;
}
lockfile = fdopen(fd, "w");
if (lockfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
- ns_main_earlyfatal("could not fdopen() pid file '%s': %s",
- filename, strbuf);
+ (*report)("could not fdopen() pid file '%s': %s",
+ filename, strbuf);
+ (void)close(fd);
+ cleanup_pidfile();
+ return;
}
- pid = getpid();
- if (fprintf(lockfile, "%ld\n", (long)pid) < 0)
- ns_main_earlyfatal("fprintf() to pid file '%s' failed",
- filename);
- if (fflush(lockfile) == EOF)
- ns_main_earlyfatal("fflush() to pid file '%s' failed",
- filename);
+ pid = getpid();
+
+ if (fprintf(lockfile, "%ld\n", (long)pid) < 0) {
+ (*report)("fprintf() to pid file '%s' failed", filename);
+ (void)fclose(fd);
+ cleanup_pidfile();
+ return;
+ }
+ if (fflush(lockfile) == EOF) {
+ (*report)("fflush() to pid file '%s' failed", filename);
+ (void)fclose(fd);
+ cleanup_pidfile();
+ return;
+ }
(void)fclose(lockfile);
}