1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r24246: Avoid the annoying 'probable memory leak in ldb' messages, by fixing

some issues in the NBT server (this was a false positive, but easily
worked around) and DRSUAPI server.

We should take care not to use the ldb_context as a talloc pool, and
to always ensure that any results from ldb_search() are moved off that
pool with talloc_steal or talloc_free().

To work around the issue in provision, for which I can find no fault
(other than a lot of work being done in provision), I've moved the
detector trigger to 400 additional blocks.

This fixes Bug #4810 by <mwallnoefer@yahoo.de>

Andrew Bartlett
(This used to be commit 42bcf85620)
This commit is contained in:
Andrew Bartlett 2007-08-06 03:01:59 +00:00 committed by Gerald (Jerry) Carter
parent b351641c6e
commit 58d9f6ed9d
3 changed files with 11 additions and 9 deletions

View File

@ -80,7 +80,7 @@ static int ldb_wrap_destructor(struct ldb_context *ldb)
{
size_t *startup_blocks = (size_t *)ldb_get_opaque(ldb, "startup_blocks");
if (startup_blocks &&
talloc_total_blocks(ldb) > *startup_blocks + 100) {
talloc_total_blocks(ldb) > *startup_blocks + 400) {
DEBUG(0,("WARNING: probable memory leak in ldb %s - %lu blocks (startup %lu) %lu bytes\n",
(char *)ldb_get_opaque(ldb, "wrap_url"),
(unsigned long)talloc_total_blocks(ldb),
@ -88,6 +88,8 @@ static int ldb_wrap_destructor(struct ldb_context *ldb)
(unsigned long)talloc_total_size(ldb)));
#if 0
talloc_report_full(ldb, stdout);
call_backtrace();
smb_panic("probable memory leak in ldb");
#endif
}
return 0;

View File

@ -58,9 +58,9 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
return;
}
partitions_basedn = samdb_partitions_dn(samctx, samctx);
partitions_basedn = samdb_partitions_dn(samctx, packet);
ret = gendb_search(samctx, samctx, partitions_basedn, &ref_res, ref_attrs,
ret = gendb_search(samctx, packet, partitions_basedn, &ref_res, ref_attrs,
"(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))",
name->name);
@ -128,9 +128,9 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
return;
}
partitions_basedn = samdb_partitions_dn(samctx, samctx);
partitions_basedn = samdb_partitions_dn(samctx, packet);
ret = gendb_search(samctx, samctx, partitions_basedn, &ref_res, ref_attrs,
ret = gendb_search(samctx, packet, partitions_basedn, &ref_res, ref_attrs,
"(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))",
name->name);
@ -140,7 +140,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
}
/* try and find the domain */
ret = gendb_search_dn(samctx, samctx,
ret = gendb_search_dn(samctx, packet,
samdb_result_dn(samctx, samctx, ref_res[0], "ncName", NULL),
&dom_res, dom_attrs);
if (ret != 1) {

View File

@ -556,7 +556,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
struct ldb_dn *domain_dn;
struct ldb_result *res_domain;
struct ldb_result *res_account;
struct ldb_dn *ntds_dn = ldb_dn_copy(b_state->sam_ctx, res->msgs[i]->dn);
struct ldb_dn *ntds_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
struct ldb_dn *ref_dn
= ldb_msg_find_attr_as_dn(b_state->sam_ctx,
@ -617,9 +617,9 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
struct ldb_dn *domain_dn;
struct ldb_result *res_domain;
struct ldb_result *res_account;
struct ldb_dn *ntds_dn = ldb_dn_copy(b_state->sam_ctx, res->msgs[i]->dn);
struct ldb_dn *ntds_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
struct ldb_result *res_ntds;
struct ldb_dn *site_dn = ldb_dn_copy(b_state->sam_ctx, res->msgs[i]->dn);
struct ldb_dn *site_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
struct ldb_result *res_site;
struct ldb_dn *ref_dn
= ldb_msg_find_attr_as_dn(b_state->sam_ctx,