1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

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 commit is contained in:
Martin Pool 0001-01-01 00:00:00 +00:00
parent 5f6feb55d7
commit bcb443c5c4
5 changed files with 97 additions and 7 deletions

View File

@ -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)

View File

@ -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

70
source/lib/dmallocmsg.c Normal file
View File

@ -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"));
}

View File

@ -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);

View File

@ -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