Forward port the change to talloc_init() to make all talloc contexts
authorJeremy Allison <jra@samba.org>
Fri, 20 Dec 2002 20:23:06 +0000 (20:23 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 20 Dec 2002 20:23:06 +0000 (20:23 +0000)
named. Ensure we can query them.
Jeremy.
(This used to be commit 842e08e52a665ae678eea239759bb2de1a0d7b33)

40 files changed:
source3/auth/auth.c
source3/include/talloc.h
source3/lib/talloc.c
source3/lib/tallocmsg.c
source3/libads/ldap.c
source3/libads/ldap_user.c
source3/libsmb/clientgen.c
source3/libsmb/clisecdesc.c
source3/locking/posix.c
source3/nmbd/nmbd.c
source3/nsswitch/winbindd.c
source3/nsswitch/winbindd_ads.c
source3/nsswitch/winbindd_group.c
source3/nsswitch/winbindd_pam.c
source3/nsswitch/winbindd_rpc.c
source3/nsswitch/winbindd_user.c
source3/nsswitch/winbindd_util.c
source3/param/loadparm.c
source3/passdb/passdb.c
source3/passdb/pdb_interface.c
source3/printing/notify.c
source3/printing/nt_printing.c
source3/registry/reg_objects.c
source3/rpc_parse/parse_misc.c
source3/rpc_server/srv_pipe_hnd.c
source3/rpc_server/srv_samr_nt.c
source3/rpc_server/srv_spoolss_nt.c
source3/rpc_server/srv_srvsvc_nt.c
source3/rpcclient/cmd_samr.c
source3/rpcclient/rpcclient.c
source3/smbd/nttrans.c
source3/smbd/server.c
source3/torture/vfstest.c
source3/utils/net_ads.c
source3/utils/net_rpc.c
source3/utils/net_rpc_join.c
source3/utils/net_rpc_samsync.c
source3/utils/smbcacls.c
source3/utils/smbcontrol.c
source3/wrepld/server.c

index d730e39f44401e657db2c04bbb77a456d8549935..dce14ed468758710fe80525faa8496ff093371ac 100644 (file)
@@ -74,9 +74,9 @@ static const uint8 *get_ntlm_challenge(struct auth_context *auth_context)
                        continue;
                }
 
-               mem_ctx = talloc_init_named("auth_get_challenge for module %s", auth_method->name);
+               mem_ctx = talloc_init("auth_get_challenge for module %s", auth_method->name);
                if (!mem_ctx) {
-                       smb_panic("talloc_init_named() failed!");
+                       smb_panic("talloc_init() failed!");
                }
                
                challenge = auth_method->get_chal(auth_context, &auth_method->private_data, mem_ctx);
@@ -211,7 +211,7 @@ static NTSTATUS check_ntlm_password(const struct auth_context *auth_context,
                return NT_STATUS_LOGON_FAILURE;
 
        for (auth_method = auth_context->auth_method_list;auth_method; auth_method = auth_method->next) {
-               mem_ctx = talloc_init_named("%s authentication for user %s\\%s", auth_method->name, 
+               mem_ctx = talloc_init("%s authentication for user %s\\%s", auth_method->name, 
                                            user_info->domain.str, user_info->smb_name.str);
 
                nt_status = auth_method->auth(auth_context, auth_method->private_data, mem_ctx, user_info, server_info);
@@ -290,7 +290,7 @@ static NTSTATUS make_auth_context(struct auth_context **auth_context)
 {
        TALLOC_CTX *mem_ctx;
 
-       mem_ctx = talloc_init_named("authentication context");
+       mem_ctx = talloc_init("authentication context");
        
        *auth_context = talloc(mem_ctx, sizeof(**auth_context));
        if (!*auth_context) {
index 64a588304134ef7e41f1655eba8cfa7f7451a970..4badddbb88047e4a14ce0577f9df1c45baabd005 100644 (file)
@@ -32,7 +32,7 @@
  **/
 typedef struct talloc_ctx TALLOC_CTX;
 
-TALLOC_CTX *talloc_init_named(char const *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
+TALLOC_CTX *talloc_init(char const *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
 
 char *talloc_vasprintf(TALLOC_CTX *t, const char *fmt, va_list ap)
        PRINTF_ATTRIBUTE(2, 0);
index 5fffe58f9f9bd5b6c7bab416b6f75e8b1ddfdbda..f0c13753b51062fdb7a504bf270e665ffa02265b 100644 (file)
@@ -117,7 +117,7 @@ static void talloc_disenroll(TALLOC_CTX *t)
 
 
 /** Create a new talloc context. **/
-TALLOC_CTX *talloc_init(void)
+static TALLOC_CTX *talloc_init_internal(void)
 {
        TALLOC_CTX *t;
 
@@ -139,12 +139,12 @@ TALLOC_CTX *talloc_init(void)
  * Please call this in preference to talloc_init().
  **/
 
- TALLOC_CTX *talloc_init_named(char const *fmt, ...) 
+ TALLOC_CTX *talloc_init(char const *fmt, ...) 
 {
        TALLOC_CTX *t;
        va_list ap;
 
-       t = talloc_init();
+       t = talloc_init_internal();
        if (t && fmt) {
                /*
                 * t->name must not be talloced.
index 608cdad452b7717cadd35298b6369ec33a3f9220..bbe1ee60a46b152d129a66512c18884b63c025f3 100644 (file)
@@ -34,7 +34,7 @@ void msg_pool_usage(int msg_type, pid_t src_pid,
                    void *UNUSED(buf), size_t UNUSED(len))
 {
        char *reply;
-       TALLOC_CTX *reply_pool = talloc_init_named("msg_pool_usage");
+       TALLOC_CTX *reply_pool = talloc_init("msg_pool_usage");
 
        SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
        
index af9a6451fe32e9f2909da4f6b38c2ff850797033..97ccf76983a0936345aa7f835f6419132a8a3abb 100644 (file)
@@ -420,7 +420,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
 
        *res = NULL;
 
-       if (!(ctx = talloc_init()))
+       if (!(ctx = talloc_init("ads_do_paged_search")))
                return ADS_ERROR(LDAP_NO_MEMORY);
 
        /* 0 means the conversion worked but the result was empty 
@@ -642,7 +642,7 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope,
        char *utf8_exp, *utf8_path, **search_attrs = NULL;
        TALLOC_CTX *ctx;
 
-       if (!(ctx = talloc_init())) {
+       if (!(ctx = talloc_init("ads_do_search"))) {
                DEBUG(1,("ads_do_search: talloc_init() failed!"));
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
@@ -1031,7 +1031,7 @@ static ADS_STATUS ads_add_machine_acct(ADS_STRUCT *ads, const char *hostname,
        char *psp;
        unsigned acct_control;
 
-       if (!(ctx = talloc_init_named("machine_account")))
+       if (!(ctx = talloc_init("machine_account")))
                return ADS_ERROR(LDAP_NO_MEMORY);
 
        ret = ADS_ERROR(LDAP_NO_MEMORY);
@@ -1144,7 +1144,7 @@ static void dump_sd(const char *filed, struct berval **values)
        SEC_DESC   *psd = 0;
        TALLOC_CTX *ctx = 0;
 
-       if (!(ctx = talloc_init_named("sec_io_desc")))
+       if (!(ctx = talloc_init("sec_io_desc")))
                return;
 
        /* prepare data */
@@ -1246,7 +1246,7 @@ void ads_process_results(ADS_STRUCT *ads, void *res,
        void *msg;
        TALLOC_CTX *ctx;
 
-       if (!(ctx = talloc_init()))
+       if (!(ctx = talloc_init("ads_process_results")))
                return;
 
        for (msg = ads_first_entry(ads, res); msg; 
@@ -1429,7 +1429,7 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn)
 
        msg   = ads_first_entry(ads, res);
        ads_pull_sid(ads, msg, attrs[1], &sid); 
-       if (!(ctx = talloc_init_named("sec_io_desc"))) {
+       if (!(ctx = talloc_init("sec_io_desc"))) {
                ret =  ADS_ERROR(LDAP_NO_MEMORY);
                goto ads_set_sd_error;
        }
@@ -1785,7 +1785,7 @@ ADS_STATUS ads_server_info(ADS_STRUCT *ads)
        char *timestr;
        TALLOC_CTX *ctx;
 
-       if (!(ctx = talloc_init())) {
+       if (!(ctx = talloc_init("ads_server_info"))) {
                return ADS_ERROR(LDAP_NO_MEMORY);
        }
 
index b6fef24b5c19573ccbd37ea61025c1c5d1d94df2..de19e2da5ee3d4897d852120134d8b86eed16163 100644 (file)
@@ -50,7 +50,7 @@ ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user,
        if (fullname && *fullname) name = fullname;
        else name = user;
 
-       if (!(ctx = talloc_init_named("ads_add_user_acct")))
+       if (!(ctx = talloc_init("ads_add_user_acct")))
                return ADS_ERROR(LDAP_NO_MEMORY);
 
        status = ADS_ERROR(LDAP_NO_MEMORY);
@@ -88,7 +88,7 @@ ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group,
        char *new_dn;
        const char *objectClass[] = {"top", "group", NULL};
 
-       if (!(ctx = talloc_init_named("ads_add_group_acct")))
+       if (!(ctx = talloc_init("ads_add_group_acct")))
                return ADS_ERROR(LDAP_NO_MEMORY);
 
        status = ADS_ERROR(LDAP_NO_MEMORY);
index 28480043b9ba26421e56718178fd48364b5e1377..c843d49d27bda307b5dac786963e6049fea9053b 100644 (file)
@@ -262,7 +262,7 @@ struct cli_state *cli_initialise(struct cli_state *cli)
        if (!cli->outbuf || !cli->inbuf)
                 goto error;
 
-       if ((cli->mem_ctx = talloc_init_named("cli based talloc")) == NULL)
+       if ((cli->mem_ctx = talloc_init("cli based talloc")) == NULL)
                 goto error;
 
        memset(cli->outbuf, 0, cli->bufsize);
index 5de67b1e058108860ca76f579bcea510c53cf794..7dd2747ff6e08b4aae7f258a61c4ba00d9679bcb 100644 (file)
@@ -83,7 +83,7 @@ BOOL cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
        prs_struct pd;
        BOOL ret = False;
 
-       if ((mem_ctx = talloc_init()) == NULL) {
+       if ((mem_ctx = talloc_init("cli_set_secdesc")) == NULL) {
                DEBUG(0,("talloc_init failed.\n"));
                goto cleanup;
        }
index 94055de2b0750e7fdfb08e9bb3f5e8984c724d38..fcf19d21cfedfeb99ab269aac1bfcc999f653d02 100644 (file)
@@ -1003,7 +1003,7 @@ BOOL set_posix_lock(files_struct *fsp, SMB_BIG_UINT u_offset, SMB_BIG_UINT u_cou
         * semantics that if a write lock is added, then it will be first in the array.
         */
        
-       if ((l_ctx = talloc_init()) == NULL) {
+       if ((l_ctx = talloc_init("set_posix_lock")) == NULL) {
                DEBUG(0,("set_posix_lock: unable to init talloc context.\n"));
                return True; /* Not a fatal error. */
        }
@@ -1149,7 +1149,7 @@ BOOL release_posix_lock(files_struct *fsp, SMB_BIG_UINT u_offset, SMB_BIG_UINT u
                }
        }
 
-       if ((ul_ctx = talloc_init()) == NULL) {
+       if ((ul_ctx = talloc_init("release_posix_lock")) == NULL) {
                DEBUG(0,("release_posix_lock: unable to init talloc context.\n"));
                return True; /* Not a fatal error. */
        }
index 5987d70a457f7af7dad1aa375258366afdeaba9c..988127e4318696d368e072ca4589e9c443305c23 100644 (file)
@@ -95,6 +95,25 @@ static void sig_hup(int sig)
        sys_select_signal();
 }
 
+/*******************************************************************
+ Print out all talloc memory info.
+********************************************************************/
+
+void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len)
+{
+       TALLOC_CTX *ctx = talloc_init("info context");
+       char *info = NULL;
+
+       if (!ctx)
+               return;
+
+       info = talloc_describe_all(ctx);
+       if (info)
+               DEBUG(10,(info));
+       message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1 : 0, True);
+       talloc_destroy(ctx);
+}
+
 #if DUMP_CORE
 /**************************************************************************** **
  Prepare to dump a core file - carefully!
@@ -682,6 +701,7 @@ static BOOL open_sockets(BOOL isdaemon, int port)
   message_register(MSG_FORCE_ELECTION, nmbd_message_election);
   message_register(MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry);
   message_register(MSG_SHUTDOWN, nmbd_terminate);
+  message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info);
 
   DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
 
index b4d1773e9cee928958bbf06b58e8049fa1efb250..61e585902ce26261a1e4e9056fd25ce5a934f321 100644 (file)
@@ -58,6 +58,25 @@ static BOOL reload_services_file(BOOL test)
        return(ret);
 }
 
+/*******************************************************************
+ Print out all talloc memory info.
+********************************************************************/
+
+void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len)
+{
+       TALLOC_CTX *ctx = talloc_init("info context");
+       char *info = NULL;
+
+       if (!ctx)
+               return;
+
+       info = talloc_describe_all(ctx);
+       if (info)
+               DEBUG(10,(info));
+       message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1: 0, True);
+       talloc_destroy(ctx);
+}
+
 #if DUMP_CORE
 
 /**************************************************************************** **
@@ -864,6 +883,7 @@ static void usage(void)
        }
 
        register_msg_pool_usage();
+       message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info);
 
        /* Loop waiting for requests */
 
index 709b134c45106024e53b4d5b1378ad07e55b7e83..261c2f2237ae0c92cdc3ba0430a5beaa4c929e9d 100644 (file)
@@ -677,7 +677,7 @@ static NTSTATUS alternate_name(struct winbindd_domain *domain)
        ads = ads_cached_connection(domain);
        if (!ads) return NT_STATUS_UNSUCCESSFUL;
 
-       if (!(ctx = talloc_init_named("alternate_name"))) {
+       if (!(ctx = talloc_init("alternate_name"))) {
                return NT_STATUS_NO_MEMORY;
        }
 
index ab6268583f74d86c41db20f42544cd5c15b1ecbd..6b2f05f436f0ceb027d2881ebd6d2dc1f2a3c849 100644 (file)
@@ -64,7 +64,7 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
        TALLOC_CTX *mem_ctx;
        NTSTATUS status;
 
-       if (!(mem_ctx = talloc_init_named("fill_grent_mem(%s)", domain->name)))
+       if (!(mem_ctx = talloc_init("fill_grent_mem(%s)", domain->name)))
                return False;
 
        /* Initialise group membership information */
@@ -408,7 +408,7 @@ static BOOL get_sam_group_entries(struct getent_state *ent)
        if (ent->got_sam_entries)
                return False;
 
-       if (!(mem_ctx = talloc_init_named("get_sam_group_entries(%s)",
+       if (!(mem_ctx = talloc_init("get_sam_group_entries(%s)",
                                          ent->domain_name))) {
                DEBUG(1, ("get_sam_group_entries: could not create talloc context!\n")); 
                return False;
@@ -820,7 +820,7 @@ enum winbindd_result winbindd_getgroups(struct winbindd_cli_state *state)
        DEBUG(3, ("[%5d]: getgroups %s\n", state->pid,
                  state->request.data.username));
 
-       if (!(mem_ctx = talloc_init_named("winbindd_getgroups(%s)",
+       if (!(mem_ctx = talloc_init("winbindd_getgroups(%s)",
                                          state->request.data.username)))
                return WINBINDD_ERROR;
 
index 733ccb4cd652d861d1918c0a483e54d2ad5f143e..c5b68ea0583592472bfd4be9e5e6d3e1839f6bf5 100644 (file)
@@ -77,7 +77,7 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
        DEBUG(3, ("[%5d]: pam auth %s\n", state->pid,
                  state->request.data.auth.user));
 
-       if (!(mem_ctx = talloc_init_named("winbind pam auth for %s", state->request.data.auth.user))) {
+       if (!(mem_ctx = talloc_init("winbind pam auth for %s", state->request.data.auth.user))) {
                DEBUG(0, ("winbindd_pam_auth: could not talloc_init()!\n"));
                result = NT_STATUS_NO_MEMORY;
                goto done;
@@ -179,7 +179,7 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
        /* Ensure null termination */
        state->request.data.auth_crap.domain[sizeof(state->request.data.auth_crap.domain)-1]='\0';
 
-       if (!(mem_ctx = talloc_init_named("winbind pam auth crap for (utf8) %s", state->request.data.auth_crap.user))) {
+       if (!(mem_ctx = talloc_init("winbind pam auth crap for (utf8) %s", state->request.data.auth_crap.user))) {
                DEBUG(0, ("winbindd_pam_auth_crap: could not talloc_init()!\n"));
                result = NT_STATUS_NO_MEMORY;
                goto done;
index d3a418027d004b8d0516cb336dc178ea5d7586c7..ddd2fc4946c29c0224b054820dccae8856bc5fcd 100644 (file)
@@ -71,7 +71,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
 
                ctr.sam.info1 = &info1;
 
-               ctx2 = talloc_init_named("winbindd dispinfo");
+               ctx2 = talloc_init("winbindd dispinfo");
                if (!ctx2) {
                        result = NT_STATUS_NO_MEMORY;
                        goto done;
@@ -152,7 +152,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
                uint32 count = 0, start = *num_entries;
                TALLOC_CTX *mem_ctx2;
 
-               mem_ctx2 = talloc_init_named("enum_dom_groups[rpc]");
+               mem_ctx2 = talloc_init("enum_dom_groups[rpc]");
 
                status = cli_samr_enum_dom_groups(hnd->cli, mem_ctx2, &dom_pol,
                                                  &start,
@@ -212,7 +212,7 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
                uint32 count = 0, start = *num_entries;
                TALLOC_CTX *mem_ctx2;
 
-               mem_ctx2 = talloc_init_named("enum_dom_local_groups[rpc]");
+               mem_ctx2 = talloc_init("enum_dom_local_groups[rpc]");
 
                result = cli_samr_enum_als_groups( hnd->cli, mem_ctx2, &dom_pol,
                                          &start, 0xFFFF, &info2, &count);
@@ -257,7 +257,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
 
        DEBUG(3,("rpc: name_to_sid name=%s\n", name));
 
-       if (!(mem_ctx = talloc_init_named("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
+       if (!(mem_ctx = talloc_init("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
                DEBUG(0, ("talloc_init failed!\n"));
                return NT_STATUS_NO_MEMORY;
        }
@@ -587,7 +587,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
 
        *seq = DOM_SEQUENCE_NONE;
 
-       if (!(mem_ctx = talloc_init_named("sequence_number[rpc]")))
+       if (!(mem_ctx = talloc_init("sequence_number[rpc]")))
                return NT_STATUS_NO_MEMORY;
 
        /* Get sam handle */
@@ -667,7 +667,7 @@ static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
 
        DEBUG(3,("rpc: domain_sid\n"));
 
-       if (!(mem_ctx = talloc_init_named("domain_sid[rpc]")))
+       if (!(mem_ctx = talloc_init("domain_sid[rpc]")))
                return NT_STATUS_NO_MEMORY;
 
        /* Get sam handle */
index bb281463ce219d61949a4997ad86a58c539c151f..5ae2fe78702db255b0cc1cab9117fb52ac348b1f 100644 (file)
@@ -137,7 +137,7 @@ enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state)
           from the winbind_lookup_by_name() call and use it in a
           winbind_lookup_userinfo() */
     
-       if (!(mem_ctx = talloc_init_named("winbindd_getpwnam([%s]\\[%s])", 
+       if (!(mem_ctx = talloc_init("winbindd_getpwnam([%s]\\[%s])", 
                                          name_domain, name_user))) {
                DEBUG(1, ("out of memory\n"));
                return WINBINDD_ERROR;
@@ -217,7 +217,7 @@ enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
        
        /* Get some user info */
        
-       if (!(mem_ctx = talloc_init_named("winbind_getpwuid(%d)",
+       if (!(mem_ctx = talloc_init("winbind_getpwuid(%d)",
                                          state->request.data.uid))) {
 
                DEBUG(1, ("out of memory\n"));
@@ -336,7 +336,7 @@ static BOOL get_sam_user_entries(struct getent_state *ent)
        if (ent->num_sam_entries)
                return False;
 
-       if (!(mem_ctx = talloc_init_named("get_sam_user_entries(%s)",
+       if (!(mem_ctx = talloc_init("get_sam_user_entries(%s)",
                                          ent->domain_name)))
                return False;
 
@@ -531,7 +531,7 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
 
        DEBUG(3, ("[%5d]: list users\n", state->pid));
 
-       if (!(mem_ctx = talloc_init_named("winbindd_list_users")))
+       if (!(mem_ctx = talloc_init("winbindd_list_users")))
                return WINBINDD_ERROR;
 
        /* Enumerate over trusted domains */
index c1bb5cec7cac2bac3035967b6835742ac2df971d..f5b4bb44972ec4354627b7bb141a030a1db3e2b3 100644 (file)
@@ -166,7 +166,7 @@ void rescan_trusted_domains(void)
 
        DEBUG(1, ("scanning trusted domain list\n"));
 
-       if (!(mem_ctx = talloc_init_named("init_domain_list")))
+       if (!(mem_ctx = talloc_init("init_domain_list")))
                return;
 
        for (domain = _domain_list; domain; domain = domain->next) {
@@ -338,7 +338,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
 
        /* Lookup name */
 
-       if (!(mem_ctx = talloc_init_named("winbindd_lookup_name_by_sid")))
+       if (!(mem_ctx = talloc_init("winbindd_lookup_name_by_sid")))
                return False;
         
        result = domain->methods->sid_to_name(domain, mem_ctx, sid, &names, type);
index 009a94ff7f2e70c753f47366e9c9dcb85d61ad24..02f120b5343716881b871d232f1913d0f00abec9 100644 (file)
@@ -1478,7 +1478,7 @@ static char *lp_string(const char *s)
 #endif
 
        if (!lp_talloc)
-               lp_talloc = talloc_init_named("lp_talloc");
+               lp_talloc = talloc_init("lp_talloc");
 
        ret = (char *)talloc(lp_talloc, len + 100);     /* leave room for substitution */
 
index ef1c1180dd036a8dfa668693080a863b08dc03a1..ed5ddda4da3f09d0fee2547df8203552c6f6c80b 100644 (file)
@@ -139,7 +139,7 @@ NTSTATUS pdb_init_sam(SAM_ACCOUNT **user)
        TALLOC_CTX *mem_ctx;
        NTSTATUS nt_status;
        
-       mem_ctx = talloc_init_named("passdb internal SAM_ACCOUNT allocation");
+       mem_ctx = talloc_init("passdb internal SAM_ACCOUNT allocation");
 
        if (!mem_ctx) {
                DEBUG(0,("pdb_init_sam: error while doing talloc_init()\n"));
index 79ce5981490cbbcd515bc1c6753227ba0450b72e..891a29148f55a7216f9ecae35b265d77c9c625a9 100644 (file)
@@ -465,7 +465,7 @@ static NTSTATUS make_pdb_context(struct pdb_context **context)
 {
        TALLOC_CTX *mem_ctx;
 
-       mem_ctx = talloc_init_named("pdb_context internal allocation context");
+       mem_ctx = talloc_init("pdb_context internal allocation context");
 
        if (!mem_ctx) {
                DEBUG(0, ("make_pdb_context: talloc init failed!\n"));
index f55dbff47e8b0fff7da0098aa961e4399161b820..a89eb3f13c0c5613af9b17530a867f43a0c3e806 100644 (file)
@@ -146,7 +146,7 @@ static void send_spoolss_notify2_msg(struct spoolss_notify_msg *msg)
                return;
 
        if (!send_ctx)
-               send_ctx = talloc_init_named("print notify queue");
+               send_ctx = talloc_init("print notify queue");
 
        if (!send_ctx)
                goto fail;
index ab01e77c6114d609f69fa76127320cd1234f16af..31f480a4ddd0cec39d900c9849f95cd0a76f94a0 100644 (file)
@@ -2574,7 +2574,7 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2, GUID guid)
 static WERROR publish_it(NT_PRINTER_INFO_LEVEL *printer)
 {
        ADS_STATUS ads_rc;
-       TALLOC_CTX *ctx = talloc_init();
+       TALLOC_CTX *ctx = talloc_init("publish_it");
        ADS_MODLIST mods = ads_init_mods(ctx);
        char *prt_dn = NULL, *srv_dn, **srv_cn;
        void *res = NULL;
@@ -3713,7 +3713,7 @@ static WERROR save_driver_init_2(NT_PRINTER_INFO_LEVEL *printer, uint8 *data, ui
                 * saved to tdb.
                 */
 
-               if ((ctx = talloc_init()) == NULL)
+               if ((ctx = talloc_init("save_driver_init_2")) == NULL)
                        return WERR_NOMEM;
 
                if ((nt_devmode = (NT_DEVICEMODE*)malloc(sizeof(NT_DEVICEMODE))) == NULL) {
@@ -4397,7 +4397,7 @@ WERROR nt_printing_setsec(const char *printername, SEC_DESC_BUF *secdesc_ctr)
        fstring key;
        WERROR status;
 
-       mem_ctx = talloc_init();
+       mem_ctx = talloc_init("nt_printing_setsec");
        if (mem_ctx == NULL)
                return WERR_NOMEM;
 
@@ -4744,7 +4744,7 @@ BOOL print_access_check(struct current_user *user, int snum, int access_type)
 
        /* Get printer security descriptor */
 
-       if(!(mem_ctx = talloc_init())) {
+       if(!(mem_ctx = talloc_init("print_access_check"))) {
                errno = ENOMEM;
                return False;
        }
index 663435dacac8611b8eaa3b41592c854d5f44d735..3289ebfe8885155757b89ea5aab72dbdf7aa8407 100644 (file)
@@ -33,7 +33,7 @@
 void regsubkey_ctr_init( REGSUBKEY_CTR *ctr )
 {
        if ( !ctr->ctx )
-               ctr->ctx = talloc_init();
+               ctr->ctx = talloc_init("regsubkey_ctr_init for ctr %p", ctr);
 }
 
 /***********************************************************************
@@ -114,7 +114,7 @@ void regsubkey_ctr_destroy( REGSUBKEY_CTR *ctr )
 void regval_ctr_init( REGVAL_CTR *ctr )
 {
        if ( !ctr->ctx )
-               ctr->ctx = talloc_init();
+               ctr->ctx = talloc_init("regval_ctr_init for ctr %p", ctr);
 }
 
 /***********************************************************************
index 5dcb49d39944c70b68fde95d4bde4b4b9f611419..86dd85066d2c0b9f09c9520a4a600a2347c0c66f 100644 (file)
@@ -63,7 +63,7 @@ void main_loop_talloc_free(void)
 TALLOC_CTX *main_loop_talloc_get(void)
 {
     if (!main_loop_talloc) {
-        main_loop_talloc = talloc_init_named("main loop talloc (mainly parse_misc)");
+        main_loop_talloc = talloc_init("main loop talloc (mainly parse_misc)");
         if (!main_loop_talloc)
             smb_panic("main_loop_talloc: malloc fail\n");
     }
index 1695419687872ff4b9a9a7f19d1d3541c76ab636..6cdb6836eb40ebda5d2f1602015b732a796f400a 100644 (file)
@@ -293,7 +293,7 @@ static void *make_internal_rpc_pipe_p(char *pipe_name,
 
        ZERO_STRUCTP(p);
 
-       if ((p->mem_ctx = talloc_init()) == NULL) {
+       if ((p->mem_ctx = talloc_init("pipe %s %p", pipe_name, p)) == NULL) {
                DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n"));
                SAFE_FREE(p);
                return NULL;
@@ -544,7 +544,7 @@ void free_pipe_context(pipes_struct *p)
                DEBUG(3,("free_pipe_context: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) ));
                talloc_destroy_pool(p->mem_ctx);
        } else {
-               p->mem_ctx = talloc_init();
+               p->mem_ctx = talloc_init("pipe %s %p", p->name, p);
                if (p->mem_ctx == NULL)
                        p->fault_state = True;
        }
index e8474118cde9cfba6c54ea1bda146ec7ab33d2cd..3e3baedb9a06fbc6e3e01800160191725f565b48 100644 (file)
@@ -134,7 +134,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
                fstrcpy(sid_str,"(NULL)");
        }
 
-       mem_ctx = talloc_init_named("samr_info for domain sid %s", sid_str);
+       mem_ctx = talloc_init("samr_info for domain sid %s", sid_str);
 
        if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL)
                return NULL;
index b5c5749f3c97faa00fd2d73de1b7e22b06691f85..68a2dcb83d5cd11de9878509d0a12d31683f909d 100644 (file)
@@ -776,7 +776,7 @@ static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr )
        if ( !ctr )
                return;
 
-       ctr->ctx = talloc_init();
+       ctr->ctx = talloc_init("notify_msg_ctr_init %p", ctr);
                
        return;
 }
index 0384bb81a33bfed711d3a1e4fe3892d93b25523e..69f82bb96f268bdbd7d45cb7ab883bf7ea3ec319 100644 (file)
@@ -237,7 +237,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC
        fstring key;
        BOOL ret = False;
 
-       mem_ctx = talloc_init();
+       mem_ctx = talloc_init("set_share_security");
        if (mem_ctx == NULL)
                return False;
 
@@ -327,7 +327,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u
        NT_USER_TOKEN *token = NULL;
        BOOL ret = True;
 
-       mem_ctx = talloc_init();
+       mem_ctx = talloc_init("share_access_check");
        if (mem_ctx == NULL)
                return False;
 
index 246e74dc359b7a9d3f36c2f9ea4103b6b2e8b0db..5c6308d07c56a754bbea289f4b9f15862bccd686 100644 (file)
@@ -1310,7 +1310,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli,
        SEC_DESC_BUF *sec_desc_buf=NULL;
        BOOL domain = False;
 
-       ctx=talloc_init();
+       ctx=talloc_init("cmd_samr_query_sec_obj");
        
        if ((argc < 1) || (argc > 2)) {
                printf("Usage: %s [rid|-d]\n", argv[0]);
index 646a6d9035612574362b0d59dfbbbf9bae4e5e52..02fa91cf267d1939e19ac17191b24608d468c2d9 100644 (file)
@@ -197,7 +197,7 @@ static void fetch_machine_sid(struct cli_state *cli)
 
        if (got_domain_sid) return;
 
-       if (!(mem_ctx=talloc_init()))
+       if (!(mem_ctx=talloc_init("fetch_machine_sid")))
        {
                DEBUG(0,("fetch_machine_sid: talloc_init returned NULL!\n"));
                goto error;
@@ -479,7 +479,7 @@ static NTSTATUS do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry,
 
                 /* Create mem_ctx */
 
-                if (!(mem_ctx = talloc_init())) {
+                if (!(mem_ctx = talloc_init("do_cmd"))) {
                         DEBUG(0, ("talloc_init() failed\n"));
                         goto done;
                 }
index bdefa6c4c1dcf8393e1fcae53781d15e486b0b05..740f450db6feabd66f4aef3c9b90018296819c30 100644 (file)
@@ -985,7 +985,7 @@ static NTSTATUS set_sd(files_struct *fsp, char *data, uint32 sd_len, uint32 secu
         * Init the parse struct we will unmarshall from.
         */
 
-       if ((mem_ctx = talloc_init()) == NULL) {
+       if ((mem_ctx = talloc_init("set_sd")) == NULL) {
                DEBUG(0,("set_sd: talloc_init failed.\n"));
                return NT_STATUS_NO_MEMORY;
        }
@@ -1538,7 +1538,7 @@ static int call_nt_transact_query_security_desc(connection_struct *conn,
 
        *ppparams = params;
 
-       if ((mem_ctx = talloc_init()) == NULL) {
+       if ((mem_ctx = talloc_init("call_nt_transact_query_security_desc")) == NULL) {
                DEBUG(0,("call_nt_transact_query_security_desc: talloc_init failed.\n"));
                return ERROR_DOS(ERRDOS,ERRnomem);
        }
index 68792117ea15335977690f1de7b3d9bbb632ea94..9bc02c3e17578451f0dbded44b5df20475662427 100644 (file)
@@ -467,6 +467,25 @@ BOOL reload_services(BOOL test)
        return(ret);
 }
 
+/*******************************************************************
+ Print out all talloc memory info.
+********************************************************************/
+
+void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len)
+{
+       TALLOC_CTX *ctx = talloc_init("info context");
+       char *info = NULL;
+
+       if (!ctx)
+               return;
+
+       info = talloc_describe_all(ctx);
+       if (info)
+               DEBUG(10,(info));
+       message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1 : 0, True);
+       talloc_destroy(ctx);
+}
+
 #if DUMP_CORE
 /*******************************************************************
 prepare to dump a core file - carefully!
@@ -763,19 +782,18 @@ static BOOL init_structs(void )
                setpgid( (pid_t)0, (pid_t)0);
 #endif
 
-       if (!directory_exist(lp_lockdir(), NULL)) {
+       if (!directory_exist(lp_lockdir(), NULL))
                mkdir(lp_lockdir(), 0755);
-       }
 
-       if (is_daemon) {
+       if (is_daemon)
                pidfile_create("smbd");
-       }
 
-       if (!message_init()) {
+       if (!message_init())
                exit(1);
-       }
+
        register_msg_pool_usage();
        register_dmalloc_msgs();
+       message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info);
 
        if (!print_backend_init())
                exit(1);
@@ -844,7 +862,6 @@ static BOOL init_structs(void )
 
        /* register our message handlers */
        message_register(MSG_SMB_FORCE_TDIS, msg_force_tdis);
-       talloc_init_named("dummy!");
 
        smbd_process();
        
index c68d2b04d2ce3d939691856047ab92f12b32988b..c8250f15f80cd1e913a681cf7822c740c34dcb29 100644 (file)
@@ -304,7 +304,7 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
 
                if (mem_ctx == NULL) {
                        /* Create mem_ctx */
-                       if (!(mem_ctx = talloc_init())) {
+                       if (!(mem_ctx = talloc_init("do_cmd"))) {
                                DEBUG(0, ("talloc_init() failed\n"));
                                goto done;
                        }
index f0ea82d87c7f83151922126115c934207bb48a45..72dbe49c164b3703c8b50124761427101c4e37df 100644 (file)
@@ -180,7 +180,7 @@ static int net_ads_workgroup(int argc, const char **argv)
 
        if (!(ads = ads_startup())) return -1;
 
-       if (!(ctx = talloc_init_named("net_ads_workgroup"))) {
+       if (!(ctx = talloc_init("net_ads_workgroup"))) {
                return -1;
        }
 
@@ -748,7 +748,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
        struct in_addr          server_ip;
        NTSTATUS nt_status;
        extern char *opt_workgroup;
-       TALLOC_CTX *mem_ctx = talloc_init();
+       TALLOC_CTX *mem_ctx = talloc_init("net_ads_printer_publish");
        ADS_MODLIST mods = ads_init_mods(mem_ctx);
        char *prt_dn, *srv_dn, **srv_cn;
        void *res = NULL;
index 092d625ae50d0ba1ca65c211de36b1fe9ec7b963..2b2a69eb99c2f89fffb4f542b62df9086ab1d590 100644 (file)
@@ -62,7 +62,7 @@ static DOM_SID *net_get_remote_domain_sid(struct cli_state *cli)
                goto error;
        }
            
-       if (!(mem_ctx=talloc_init()))
+       if (!(mem_ctx=talloc_init("net_get_remote_domain_sid")))
        {
                DEBUG(0,("net_get_remote_domain_sid: talloc_init returned NULL!\n"));
                goto error;
@@ -138,7 +138,7 @@ static int run_rpc_command(struct cli_state *cli_arg, const int pipe_idx, int co
 
        /* Create mem_ctx */
        
-       if (!(mem_ctx = talloc_init())) {
+       if (!(mem_ctx = talloc_init("run_rpc_command"))) {
                DEBUG(0, ("talloc_init() failed\n"));
                cli_shutdown(cli);
                return -1;
@@ -374,7 +374,7 @@ rpc_info_internals(const DOM_SID *domain_sid, struct cli_state *cli,
        result = cli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
                                         2, &ctr);
        if (NT_STATUS_IS_OK(result)) {
-               TALLOC_CTX *ctx = talloc_init();
+               TALLOC_CTX *ctx = talloc_init("rpc_info_internals");
                d_printf("Domain Name: %s\n", unistr2_tdup(ctx, &ctr.info.inf2.uni_domain));
                d_printf("Domain SID: %s\n", sid_str);
                d_printf("Sequence number: %u\n", ctr.info.inf2.seq_num);
@@ -1721,7 +1721,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
                return -1;
        }
 
-       if (!(mem_ctx = talloc_init_named("establishing trust relationship to domain %s",
+       if (!(mem_ctx = talloc_init("establishing trust relationship to domain %s",
                        domain_name))) {
                DEBUG(0, ("talloc_init() failed\n"));
                cli_shutdown(cli);
@@ -1743,7 +1743,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
         * Call LsaOpenPolicy and LsaQueryInfo
         */
         
-       if (!(mem_ctx = talloc_init())) {
+       if (!(mem_ctx = talloc_init("rpc_trustdom_establish"))) {
                DEBUG(0, ("talloc_init() failed\n"));
                cli_shutdown(cli);
                return -1;
@@ -1903,7 +1903,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
         * Listing trusted domains (stored in secrets.tdb, if local)
         */
 
-       mem_ctx = talloc_init_named("trust relationships listing");
+       mem_ctx = talloc_init("trust relationships listing");
 
        /*
         * set domain and pdc name to local samba server (default)
index 4b78b7d283defb84955e2ebcca4b9c3338725525..1b711f7b432a7b6907cf1f5055a86eb65e432e1d 100644 (file)
@@ -141,7 +141,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
        if (!(cli = net_make_ipc_connection(NET_FLAGS_PDC))) 
                return 1;
 
-       if (!(mem_ctx = talloc_init())) {
+       if (!(mem_ctx = talloc_init("net_rpc_join_newstyle"))) {
                DEBUG(0, ("Could not initialise talloc context\n"));
                goto done;
        }
index 34d926ab614164802bab9e0cf63e8322ee0ea227..1bd39e3ebb3ff1dc8a2fc0cd44873e48c58b11cf 100644 (file)
@@ -128,7 +128,7 @@ static void dump_database(struct cli_state *cli, unsigned db_type, DOM_CRED *ret
         SAM_DELTA_CTR *deltas;
         uint32 num_deltas;
 
-       if (!(mem_ctx = talloc_init())) {
+       if (!(mem_ctx = talloc_init("dump_database"))) {
                return;
        }
 
@@ -452,7 +452,7 @@ fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
 
        d_printf("Group members of %s: ", grp->gr_name);
 
-       if (!(t = talloc_init())) {
+       if (!(t = talloc_init("fetch_group_mem_info"))) {
                DEBUG(0, ("could not talloc_init\n"));
                return NT_STATUS_NO_MEMORY;
        }
@@ -656,7 +656,7 @@ fetch_database(struct cli_state *cli, unsigned db_type, DOM_CRED *ret_creds,
         SAM_DELTA_CTR *deltas;
         uint32 num_deltas;
 
-       if (!(mem_ctx = talloc_init())) {
+       if (!(mem_ctx = talloc_init("fetch_database"))) {
                return;
        }
 
index 043aa689cc9fbd3c4ecd90955f6ab78ef2979e62..07b2aa7fec91a1fb07f64f5d0d9ae33f53eb691f 100644 (file)
@@ -777,7 +777,7 @@ You can string acls together with spaces, commas or newlines\n\
 
        struct cli_state *cli;
 
-       ctx=talloc_init();
+       ctx=talloc_init("main");
 
        setlinebuf(stdout);
 
index 72ac2dd095fe8305d03eeb53a9c8ebf1e4b8e562..f4d197147fe1386d0807ae7c79d847843ea1b479 100644 (file)
@@ -43,6 +43,7 @@ static struct {
        {"dmalloc-log-changed", MSG_REQ_DMALLOC_LOG_CHANGED },
        {"shutdown", MSG_SHUTDOWN },
        {"drvupgrade", MSG_PRINTER_DRVUPGRADE},
+       {"tallocdump", MSG_REQ_TALLOC_USAGE},
        {NULL, -1}
 };
 
@@ -75,8 +76,10 @@ static void usage(BOOL doexit)
 
 static int pong_count;
 static BOOL got_level;
+static BOOL got_pool;
 static BOOL pong_registered = False;
 static BOOL debuglevel_registered = False;
+static BOOL poolusage_registered = False;
 static BOOL profilelevel_registered = False;
 
 
@@ -108,6 +111,22 @@ void pong_function(int msg_type, pid_t src, void *buf, size_t len)
        printf("PONG from PID %u\n",(unsigned int)src);
 }
 
+/****************************************************************************
+ Prints out the current talloc list.
+****************************************************************************/
+void tallocdump_function(int msg_type, pid_t src, void *buf, size_t len)
+{
+       char *info = (char *)buf;
+
+       printf("Current talloc contexts for process %u\n", (unsigned int)src );
+       if (len == 0)
+               printf("None returned\n");
+       else
+               printf(info);
+       printf("\n");
+       got_pool = True;
+}
+
 /****************************************************************************
 Prints out the current Debug level returned by MSG_DEBUGLEVEL
 ****************************************************************************/
@@ -347,6 +366,25 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
                }
                break;
 
+       case MSG_REQ_TALLOC_USAGE:
+               if (!poolusage_registered) {
+                       message_register(MSG_TALLOC_USAGE, tallocdump_function);
+                       poolusage_registered = True;
+               }
+               got_pool = False;
+               retval = send_message(dest, MSG_REQ_TALLOC_USAGE, NULL, 0, True);
+               if (retval) {
+                       timeout_start = time(NULL);
+                       while (!got_pool) {
+                               message_dispatch();
+                               if ((time(NULL) - timeout_start) > MAX_WAIT) {
+                                       fprintf(stderr,"tallocdump timeout\n");
+                                       break;
+                               }
+                       }
+               }
+               break;
+
        case MSG_REQ_DEBUGLEVEL:
                if (!debuglevel_registered) {
                    message_register(MSG_DEBUGLEVEL, debuglevel_function);
index 295eb15596a532316b73467ceebbc210d460937c..144a5b570ce8eb48bb6716d39a5087cdb25536a2 100644 (file)
@@ -707,7 +707,7 @@ static void process(void)
        }
 
        /* Initialise the memory context */
-       mem_ctx=talloc_init_named("wins repl talloc ctx");
+       mem_ctx=talloc_init("wins repl talloc ctx");
 
        /* initialise the global partners table */
        partner_count=init_wins_partner_table();