summaryrefslogtreecommitdiff
path: root/server/main.c
diff options
context:
space:
mode:
authorGravatar Lucien Van Elsen <lwvanels@mit.edu>1992-08-10 09:23:10 +0000
committerGravatar Lucien Van Elsen <lwvanels@mit.edu>1992-08-10 09:23:10 +0000
commit107f9dc3fbffeeab97b19ac161ab5b8bc18af544 (patch)
treef4f4d680cd7e1aba76907480adac9f93b16d22fe /server/main.c
parent75260acd8367ea84b91dc9269f2d061048ff5548 (diff)
added support for debugging malloc
Diffstat (limited to 'server/main.c')
-rw-r--r--server/main.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/main.c b/server/main.c
index eac9c33..ffafdd5 100644
--- a/server/main.c
+++ b/server/main.c
@@ -126,6 +126,10 @@ u_short hm_port; /* the port # of the host manager */
char *programname; /* set to the basename of argv[0] */
char myname[MAXHOSTNAMELEN]; /* my host name */
int zdebug;
+#ifdef DEBUG_MALLOC
+int dump_malloc_stats = 0;
+unsigned long m_size;
+#endif
#ifdef DEBUG
int zalone;
#endif /* DEBUG */
@@ -320,6 +324,9 @@ main(argc, argv)
/* GO! */
uptime = NOW;
+#ifdef DEBUG_MALLOC
+ malloc_inuse(&m_size);
+#endif
for EVER {
if (doreset)
do_reset();
@@ -355,6 +362,15 @@ main(argc, argv)
if (nfound < 0) {
if (errno != EINTR)
syslog(LOG_WARNING, "select error: %m");
+#ifdef DEBUG_MALLOC
+ if (dump_malloc_stats) {
+ unsigned long foo,histid2;
+ dump_malloc_stats = 0;
+ foo = malloc_inuse(&histid2);
+ printf("Total inuse: %d\n",foo);
+ malloc_list(2,m_size,histid2);
+ }
+#endif
continue;
}
if (nfound == 0)
@@ -532,6 +548,9 @@ static SIGNAL_RETURN_TYPE
dbug_on(int sig)
{
syslog(LOG_DEBUG, "debugging turned on");
+#ifdef DEBUG_MALLOC
+ dump_malloc_stats = 1;
+#endif
zdebug = 1;
SIG_RETURN;
}
@@ -540,6 +559,9 @@ static SIGNAL_RETURN_TYPE
dbug_off(int sig)
{
syslog(LOG_DEBUG, "debugging turned off");
+#ifdef DEBUG_MALLOC
+ malloc_inuse(&m_size);
+#endif
zdebug = 0;
SIG_RETURN;
}