diff options
author | Martin Pool <mbp@samba.org> | 2002-01-09 08:27:15 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2002-01-09 08:27:15 +0000 |
commit | 6c7050ea95001c6de6085f93e3d6332ed2c3aa60 (patch) | |
tree | 68e3d6470f8e4243c8f2cdc06ae2b1d9548cad36 | |
parent | a56f0e93ea775ede87de478f9b09de2daa72ca27 (diff) | |
download | samba-6c7050ea95001c6de6085f93e3d6332ed2c3aa60.tar.gz samba-6c7050ea95001c6de6085f93e3d6332ed2c3aa60.tar.bz2 samba-6c7050ea95001c6de6085f93e3d6332ed2c3aa60.zip |
Add two more memory-debug smbcontrol messages: these ones should
prompt dmalloc to log information about what happening, so you can see
in flight why smbd is getting bloated.
(This used to be commit bcb443c5c4bf97fe6b5b0993e42496c2e64f0124)
-rw-r--r-- | source3/Makefile.in | 2 | ||||
-rw-r--r-- | source3/include/messages.h | 8 | ||||
-rw-r--r-- | source3/lib/dmallocmsg.c | 70 | ||||
-rw-r--r-- | source3/smbd/server.c | 1 | ||||
-rw-r--r-- | source3/utils/smbcontrol.c | 23 |
5 files changed, 97 insertions, 7 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index ed1f468711..8920cea648 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -121,7 +121,7 @@ LIB_OBJ = lib/charcnv.o lib/debug.o lib/fault.o \ lib/util.o lib/util_sock.o lib/util_sec.o smbd/ssl.o \ lib/talloc.o lib/hash.o lib/substitute.o lib/fsusage.o \ lib/ms_fnmatch.o lib/select.o lib/error.o lib/messages.o \ - lib/tallocmsg.o \ + lib/tallocmsg.o lib/dmallocmsg.o \ lib/md5.o lib/hmacmd5.o lib/iconv.o lib/smbpasswd.o \ nsswitch/wb_client.o nsswitch/wb_common.o \ intl/lang_tdb.o lib/account_pol.o $(TDB_OBJ) diff --git a/source3/include/messages.h b/source3/include/messages.h index f1cfb50836..2b0c1ad1af 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -3,6 +3,7 @@ Version 3.0 messages.c header Copyright (C) Andrew Tridgell 2000 + Copyright (C) 2001, 2002 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,6 +35,13 @@ #define MSG_REQ_POOL_USAGE 9 #define MSG_POOL_USAGE 10 +/* If dmalloc is included, set a steady-state mark */ +#define MSG_REQ_DMALLOC_MARK 11 + +/* If dmalloc is included, dump to the dmalloc log a description of + * what has changed since the last MARK */ +#define MSG_REQ_DMALLOC_LOG_CHANGED 12 + /* nmbd messages */ #define MSG_FORCE_ELECTION 1001 diff --git a/source3/lib/dmallocmsg.c b/source3/lib/dmallocmsg.c new file mode 100644 index 0000000000..9d6ac87aeb --- /dev/null +++ b/source3/lib/dmallocmsg.c @@ -0,0 +1,70 @@ +/* + samba -- Unix SMB/Netbios implementation. + Copyright (C) 2002 by Martin Pool + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/** + * @file dmallocmsg.c + * + * Glue code to cause dmalloc info to come out when we receive a prod + * over samba messaging. + **/ + +static unsigned long our_dm_mark = 0; + + +/** + * Respond to a POOL_USAGE message by sending back string form of memory + * usage stats. + **/ +static void msg_req_dmalloc_mark(int UNUSED(msg_type), pid_t UNUSED(src_pid), + void *UNUSED(buf), size_t UNUSED(len)) +{ +#ifdef ENABLE_DMALLOC + our_dm_mark = dmalloc_mark(); + DEBUG(2,("Got MSG_REQ_DMALLOC_MARK: mark set\n")); +#else + DEBUG(2,("Got MSG_REQ_DMALLOC_MARK but dmalloc not in this process\n")); +#endif +} + + + +static void msg_req_dmalloc_log_changed(int UNUSED(msg_type), + pid_t UNUSED(src_pid), + void *UNUSED(buf), size_t UNUSED(len)) +{ +#ifdef ENABLE_DMALLOC + dmalloc_log_changed(our_dm_mark, True, True, True); + DEBUG(2,("Got MSG_REQ_DMALLOC_LOG_CHANGED: done\n")); +#else + DEBUG(2,("Got MSG_REQ_DMALLOC_LOG_CHANGED but dmalloc not in this process\n")); +#endif +} + + +/** + * Register handler for MSG_REQ_POOL_USAGE + **/ +void register_dmalloc_msgs(void) +{ + message_register(MSG_REQ_DMALLOC_MARK, msg_req_dmalloc_mark); + message_register(MSG_REQ_DMALLOC_LOG_CHANGED, msg_req_dmalloc_log_changed); + DEBUG(2, ("Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED\n")); +} diff --git a/source3/smbd/server.c b/source3/smbd/server.c index b523659dbf..2f831cdd97 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -809,6 +809,7 @@ static void usage(char *pname) exit(1); } register_msg_pool_usage(); + register_dmalloc_msgs(); /* Setup the main smbd so that we can get messages. */ claim_connection(NULL,"",MAXSTATUS,True); diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index f03387c6e0..318e1657cc 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -3,7 +3,7 @@ Version 3.0 program to send control messages to Samba processes Copyright (C) Andrew Tridgell 1994-1998 - Copyright (C) 2001 by Martin Pool + Copyright (C) 2001, 2002 by Martin Pool This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,6 +39,8 @@ static struct { {"samsync", MSG_SMB_SAM_SYNC}, {"samrepl", MSG_SMB_SAM_REPL}, {"pool-usage", MSG_REQ_POOL_USAGE }, + {"dmalloc-mark", MSG_REQ_DMALLOC_MARK }, + {"dmalloc-log-changed", MSG_REQ_DMALLOC_LOG_CHANGED }, {NULL, -1} }; @@ -68,7 +70,6 @@ static BOOL got_level; static BOOL pong_registered = False; static BOOL debuglevel_registered = False; static BOOL profilelevel_registered = False; -static BOOL pool_usage_registered = False; /** @@ -216,6 +217,12 @@ static int parse_type(char *mtype) } +static void register_all(void) +{ + message_register(MSG_POOL_USAGE, pool_usage_cb); +} + + /**************************************************************************** do command ****************************************************************************/ @@ -404,15 +411,17 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params) break; case MSG_REQ_POOL_USAGE: - if (!pool_usage_registered) { - message_register(MSG_POOL_USAGE, pool_usage_cb); - pool_usage_registered = True; - } if (!send_message(dest, MSG_REQ_POOL_USAGE, NULL, 0, True)) return False; wait_for_replies(MAX_WAIT, NULL); break; + + case MSG_REQ_DMALLOC_LOG_CHANGED: + case MSG_REQ_DMALLOC_MARK: + if (!send_message(dest, mtype, NULL, 0, False)) + return False; + break; } return (True); @@ -453,6 +462,8 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params) argc -= optind; argv = &argv[optind]; + register_all(); + if (!interactive) { if (argc < 2) usage(True); /* Need to invert sense of return code -- samba |