mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
982. [func] If "memstatistics-file" is set in options the memory
statistics will be written to it.
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,3 +1,5 @@
|
||||
982. [func] If "memstatistics-file" is set in options the memory
|
||||
statistics will be written to it.
|
||||
|
||||
981. [func] The dnssec tools can now take multiple '-r randomfile'
|
||||
arguments.
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: main.c,v 1.119 2001/08/08 22:54:20 gson Exp $ */
|
||||
/* $Id: main.c,v 1.120 2001/09/06 02:13:48 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <isc/os.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/resource.h>
|
||||
#include <isc/stdio.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/util.h>
|
||||
@@ -532,6 +533,7 @@ cleanup(void) {
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
isc_result_t result;
|
||||
static const char *memstats;
|
||||
|
||||
result = isc_file_progname(*argv, program_name, sizeof(program_name));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
@@ -590,6 +592,16 @@ main(int argc, char *argv[]) {
|
||||
isc_mem_stats(ns_g_mctx, stdout);
|
||||
isc_mutex_stats(stdout);
|
||||
}
|
||||
memstats = ns_os_getmemstats();
|
||||
if (memstats) {
|
||||
FILE *fp = NULL;
|
||||
result = isc_stdio_open(memstats, "w", &fp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_mem_stats(ns_g_mctx, fp);
|
||||
isc_mutex_stats(fp);
|
||||
isc_stdio_close(fp);
|
||||
}
|
||||
}
|
||||
isc_mem_destroy(&ns_g_mctx);
|
||||
|
||||
isc_app_finish();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: server.c,v 1.340 2001/08/30 05:52:12 marka Exp $ */
|
||||
/* $Id: server.c,v 1.341 2001/09/06 02:13:50 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -2044,6 +2044,13 @@ load_configuration(const char *filename, ns_server_t *server,
|
||||
else
|
||||
ns_os_writepidfile(ns_g_defaultpidfile);
|
||||
|
||||
obj = NULL;
|
||||
if (options != NULL &&
|
||||
cfg_map_get(options, "memstatistics-file", &obj) == ISC_R_SUCCESS)
|
||||
ns_os_setmemstats(cfg_obj_asstring(obj));
|
||||
else
|
||||
ns_os_setmemstats(NULL);
|
||||
|
||||
obj = NULL;
|
||||
result = ns_config_get(maps, "statistics-file", &obj);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.h,v 1.14 2001/01/09 21:40:39 bwelling Exp $ */
|
||||
/* $Id: os.h,v 1.15 2001/09/06 02:13:52 marka Exp $ */
|
||||
|
||||
#ifndef NS_OS_H
|
||||
#define NS_OS_H 1
|
||||
@@ -43,6 +43,12 @@ ns_os_minprivs(void);
|
||||
void
|
||||
ns_os_writepidfile(const char *filename);
|
||||
|
||||
void
|
||||
ns_os_setmemstats(const char *filename);
|
||||
|
||||
const char *
|
||||
ns_os_getmemstats(void);
|
||||
|
||||
void
|
||||
ns_os_shutdown(void);
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.c,v 1.47 2001/08/31 05:57:45 marka Exp $ */
|
||||
/* $Id: os.c,v 1.48 2001/09/06 02:13:51 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdarg.h>
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <named/os.h>
|
||||
|
||||
static char *pidfile = NULL;
|
||||
static char *memstats = NULL;
|
||||
|
||||
/*
|
||||
* If there's no <linux/capability.h>, we don't care about <sys/prctl.h>
|
||||
@@ -515,8 +516,32 @@ ns_os_writepidfile(const char *filename) {
|
||||
(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
|
||||
ns_os_shutdown(void) {
|
||||
closelog();
|
||||
cleanup_pidfile();
|
||||
cleanup_memstats();
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.h,v 1.1 2001/07/18 03:43:18 mayer Exp $ */
|
||||
/* $Id: os.h,v 1.2 2001/09/06 02:13:55 marka Exp $ */
|
||||
|
||||
#ifndef NS_OS_H
|
||||
#define NS_OS_H 1
|
||||
@@ -43,6 +43,12 @@ ns_os_minprivs(void);
|
||||
void
|
||||
ns_os_writepidfile(const char *filename);
|
||||
|
||||
void
|
||||
ns_os_setmemstats(const char *filename);
|
||||
|
||||
const char *
|
||||
ns_os_getmemstats(void);
|
||||
|
||||
void
|
||||
ns_os_shutdown(void);
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: os.c,v 1.5 2001/08/09 23:44:13 mayer Exp $ */
|
||||
/* $Id: os.c,v 1.6 2001/09/06 02:13:54 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdarg.h>
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
|
||||
static char *pidfile = NULL;
|
||||
static char *memstats = NULL;
|
||||
|
||||
static BOOL Initialized = FALSE;
|
||||
|
||||
@@ -198,9 +199,32 @@ ns_os_writepidfile(const char *filename) {
|
||||
(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
|
||||
ns_os_shutdown(void) {
|
||||
closelog();
|
||||
cleanup_pidfile();
|
||||
cleanup_memstats();
|
||||
ntservice_shutdown(); /* This MUST be the last thing done */
|
||||
}
|
||||
|
Reference in New Issue
Block a user