mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
ns_os_*memstats() -> ns_main_setmemstats()
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: main.h,v 1.8 2001/08/08 22:54:26 gson Exp $ */
|
/* $Id: main.h,v 1.9 2001/09/07 00:36:55 marka Exp $ */
|
||||||
|
|
||||||
#ifndef NAMED_MAIN_H
|
#ifndef NAMED_MAIN_H
|
||||||
#define NAMED_MAIN_H 1
|
#define NAMED_MAIN_H 1
|
||||||
@@ -23,4 +23,7 @@
|
|||||||
void
|
void
|
||||||
ns_main_earlyfatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
ns_main_earlyfatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
||||||
|
|
||||||
|
void
|
||||||
|
ns_main_setmemstats(const char *);
|
||||||
|
|
||||||
#endif /* NAMED_MAIN_H */
|
#endif /* NAMED_MAIN_H */
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: main.c,v 1.121 2001/09/07 00:17:25 gson Exp $ */
|
/* $Id: main.c,v 1.122 2001/09/07 00:36:52 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -565,10 +565,28 @@ cleanup(void) {
|
|||||||
ns_log_shutdown();
|
ns_log_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *memstats = NULL;
|
||||||
|
|
||||||
|
void
|
||||||
|
ns_main_setmemstats(const char *filename) {
|
||||||
|
/*
|
||||||
|
* Caller has to ensure locking.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (memstats != NULL) {
|
||||||
|
free(memstats);
|
||||||
|
memstats = NULL;
|
||||||
|
}
|
||||||
|
if (filename == NULL)
|
||||||
|
return;
|
||||||
|
memstats = malloc(strlen(filename) + 1);
|
||||||
|
if (memstats)
|
||||||
|
strcpy(memstats, filename);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
static const char *memstats;
|
|
||||||
|
|
||||||
result = isc_file_progname(*argv, program_name, sizeof(program_name));
|
result = isc_file_progname(*argv, program_name, sizeof(program_name));
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
@@ -627,8 +645,7 @@ main(int argc, char *argv[]) {
|
|||||||
isc_mem_stats(ns_g_mctx, stdout);
|
isc_mem_stats(ns_g_mctx, stdout);
|
||||||
isc_mutex_stats(stdout);
|
isc_mutex_stats(stdout);
|
||||||
}
|
}
|
||||||
memstats = ns_os_getmemstats();
|
if (memstats != NULL) {
|
||||||
if (memstats) {
|
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
result = isc_stdio_open(memstats, "w", &fp);
|
result = isc_stdio_open(memstats, "w", &fp);
|
||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
@@ -639,6 +656,8 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
isc_mem_destroy(&ns_g_mctx);
|
isc_mem_destroy(&ns_g_mctx);
|
||||||
|
|
||||||
|
ns_main_setmemstats(NULL);
|
||||||
|
|
||||||
isc_app_finish();
|
isc_app_finish();
|
||||||
|
|
||||||
ns_os_shutdown();
|
ns_os_shutdown();
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: server.c,v 1.341 2001/09/06 02:13:50 marka Exp $ */
|
/* $Id: server.c,v 1.342 2001/09/07 00:36:54 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@
|
|||||||
#include <named/log.h>
|
#include <named/log.h>
|
||||||
#include <named/logconf.h>
|
#include <named/logconf.h>
|
||||||
#include <named/lwresd.h>
|
#include <named/lwresd.h>
|
||||||
|
#include <named/main.h>
|
||||||
#include <named/os.h>
|
#include <named/os.h>
|
||||||
#include <named/server.h>
|
#include <named/server.h>
|
||||||
#include <named/tkeyconf.h>
|
#include <named/tkeyconf.h>
|
||||||
@@ -2047,9 +2048,9 @@ load_configuration(const char *filename, ns_server_t *server,
|
|||||||
obj = NULL;
|
obj = NULL;
|
||||||
if (options != NULL &&
|
if (options != NULL &&
|
||||||
cfg_map_get(options, "memstatistics-file", &obj) == ISC_R_SUCCESS)
|
cfg_map_get(options, "memstatistics-file", &obj) == ISC_R_SUCCESS)
|
||||||
ns_os_setmemstats(cfg_obj_asstring(obj));
|
ns_main_setmemstats(cfg_obj_asstring(obj));
|
||||||
else
|
else
|
||||||
ns_os_setmemstats(NULL);
|
ns_main_setmemstats(NULL);
|
||||||
|
|
||||||
obj = NULL;
|
obj = NULL;
|
||||||
result = ns_config_get(maps, "statistics-file", &obj);
|
result = ns_config_get(maps, "statistics-file", &obj);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: os.h,v 1.15 2001/09/06 02:13:52 marka Exp $ */
|
/* $Id: os.h,v 1.16 2001/09/07 00:36:59 marka Exp $ */
|
||||||
|
|
||||||
#ifndef NS_OS_H
|
#ifndef NS_OS_H
|
||||||
#define NS_OS_H 1
|
#define NS_OS_H 1
|
||||||
@@ -43,12 +43,6 @@ ns_os_minprivs(void);
|
|||||||
void
|
void
|
||||||
ns_os_writepidfile(const char *filename);
|
ns_os_writepidfile(const char *filename);
|
||||||
|
|
||||||
void
|
|
||||||
ns_os_setmemstats(const char *filename);
|
|
||||||
|
|
||||||
const char *
|
|
||||||
ns_os_getmemstats(void);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ns_os_shutdown(void);
|
ns_os_shutdown(void);
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: os.c,v 1.48 2001/09/06 02:13:51 marka Exp $ */
|
/* $Id: os.c,v 1.49 2001/09/07 00:36:57 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -43,7 +43,6 @@
|
|||||||
#include <named/os.h>
|
#include <named/os.h>
|
||||||
|
|
||||||
static char *pidfile = NULL;
|
static char *pidfile = NULL;
|
||||||
static char *memstats = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there's no <linux/capability.h>, we don't care about <sys/prctl.h>
|
* If there's no <linux/capability.h>, we don't care about <sys/prctl.h>
|
||||||
@@ -516,32 +515,8 @@ ns_os_writepidfile(const char *filename) {
|
|||||||
(void)fclose(lockfile);
|
(void)fclose(lockfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
cleanup_memstats(void) {
|
|
||||||
if (memstats != NULL)
|
|
||||||
free(memstats);
|
|
||||||
memstats = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ns_os_setmemstats(const char *filename) {
|
|
||||||
|
|
||||||
cleanup_memstats();
|
|
||||||
if (filename == NULL)
|
|
||||||
return;
|
|
||||||
memstats = malloc(strlen(filename) + 1);
|
|
||||||
if (memstats)
|
|
||||||
strcpy(memstats, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
ns_os_getmemstats(void) {
|
|
||||||
return (memstats);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ns_os_shutdown(void) {
|
ns_os_shutdown(void) {
|
||||||
closelog();
|
closelog();
|
||||||
cleanup_pidfile();
|
cleanup_pidfile();
|
||||||
cleanup_memstats();
|
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: os.h,v 1.2 2001/09/06 02:13:55 marka Exp $ */
|
/* $Id: os.h,v 1.3 2001/09/07 00:37:02 marka Exp $ */
|
||||||
|
|
||||||
#ifndef NS_OS_H
|
#ifndef NS_OS_H
|
||||||
#define NS_OS_H 1
|
#define NS_OS_H 1
|
||||||
@@ -43,12 +43,6 @@ ns_os_minprivs(void);
|
|||||||
void
|
void
|
||||||
ns_os_writepidfile(const char *filename);
|
ns_os_writepidfile(const char *filename);
|
||||||
|
|
||||||
void
|
|
||||||
ns_os_setmemstats(const char *filename);
|
|
||||||
|
|
||||||
const char *
|
|
||||||
ns_os_getmemstats(void);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ns_os_shutdown(void);
|
ns_os_shutdown(void);
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: os.c,v 1.6 2001/09/06 02:13:54 marka Exp $ */
|
/* $Id: os.c,v 1.7 2001/09/07 00:37:00 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -43,7 +43,6 @@
|
|||||||
|
|
||||||
|
|
||||||
static char *pidfile = NULL;
|
static char *pidfile = NULL;
|
||||||
static char *memstats = NULL;
|
|
||||||
|
|
||||||
static BOOL Initialized = FALSE;
|
static BOOL Initialized = FALSE;
|
||||||
|
|
||||||
@@ -199,32 +198,9 @@ ns_os_writepidfile(const char *filename) {
|
|||||||
(void)fclose(lockfile);
|
(void)fclose(lockfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
|
||||||
cleanup_memstats(void) {
|
|
||||||
if (memstats != NULL)
|
|
||||||
free(memstats);
|
|
||||||
memstats = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ns_os_setmemstats(const char *filename) {
|
|
||||||
cleanup_memstats();
|
|
||||||
if (filename == NULL)
|
|
||||||
return;
|
|
||||||
memstats = malloc(strlen(filename) + 1);
|
|
||||||
if (memstats != NULL)
|
|
||||||
strcpy(memstats, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
ns_os_getmemstats(void) {
|
|
||||||
return (memstats);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ns_os_shutdown(void) {
|
ns_os_shutdown(void) {
|
||||||
closelog();
|
closelog();
|
||||||
cleanup_pidfile();
|
cleanup_pidfile();
|
||||||
cleanup_memstats();
|
|
||||||
ntservice_shutdown(); /* This MUST be the last thing done */
|
ntservice_shutdown(); /* This MUST be the last thing done */
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user