Add two more memory-debug smbcontrol messages: these ones should
[ira/wip.git] / source3 / utils / smbcontrol.c
index 9be34b132db19afd3c8f189bacddc9b3f463ab69..318e1657cc1e8367b26792bbf2913caa088f6fda 100644 (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
@@ -22,6 +22,8 @@
 
 #include "includes.h"
 
+extern BOOL AllowDebugChange;
+
 static struct {
        char *name;
        int value;
@@ -37,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}
 };
 
@@ -66,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;
 
 
 /**
@@ -149,7 +152,7 @@ void profilelevel_function(int msg_type, pid_t src, void *buf, size_t len)
  **/
 static void pool_usage_cb(int msg_type, pid_t src_pid, void *buf, size_t len)
 {
-       printf("Got POOL_USAGE reply from pid%u:\n%.*s\n",
+       printf("Got POOL_USAGE reply from pid%u:\n%.*s",
               (unsigned int) src_pid, (int) len, (const char *) buf);
 }
 
@@ -214,6 +217,12 @@ static int parse_type(char *mtype)
 }
 
 
+static void register_all(void)
+{
+       message_register(MSG_POOL_USAGE, pool_usage_cb);
+}
+
+
 /****************************************************************************
 do command
 ****************************************************************************/
@@ -402,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);
@@ -423,6 +434,9 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
        extern int optind;
        BOOL interactive = False;
 
+       AllowDebugChange = False;
+       DEBUGLEVEL = 0;
+
        setup_logging(argv[0],True);
        
        if (argc < 2) usage(True);
@@ -448,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