summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-01-09 17:11:04 -0800
committerJeremy Allison <jra@samba.org>2008-01-09 17:11:04 -0800
commitbc932b8ad4396f76b71c43efe9a6346f89c3632c (patch)
treea0f01b23835cf36108f44569ace0cee7334e39bc
parentf98c68a8a4882cb0a1b7e8985f3eba5ebb8287e3 (diff)
downloadsamba-bc932b8ad4396f76b71c43efe9a6346f89c3632c.tar.gz
samba-bc932b8ad4396f76b71c43efe9a6346f89c3632c.tar.xz
samba-bc932b8ad4396f76b71c43efe9a6346f89c3632c.zip
Make use of talloc_pool in the main codepaths. Remove the sub-contexts.
Jeremy.
-rw-r--r--source/smbd/nttrans.c8
-rw-r--r--source/smbd/open.c8
-rw-r--r--source/smbd/process.c2
-rw-r--r--source/smbd/service.c8
-rw-r--r--source/smbd/trans2.c25
-rw-r--r--source/smbd/vfs.c13
6 files changed, 12 insertions, 52 deletions
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index ae64c062156..e8df732ea23 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -1604,7 +1604,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
SEC_DESC *psd = NULL;
size_t sd_size;
uint32 security_info_wanted;
- TALLOC_CTX *frame;
files_struct *fsp = NULL;
NTSTATUS status;
DATA_BLOB blob;
@@ -1631,8 +1630,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
return;
}
- frame = talloc_stackframe();
-
/*
* Get the permissions to return.
*/
@@ -1651,7 +1648,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
}
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(frame);
reply_nterror(req, status);
return;
}
@@ -1665,7 +1661,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
if (max_data_count < sd_size) {
send_nt_replies(conn, req, NT_STATUS_BUFFER_TOO_SMALL,
params, 4, *ppdata, 0);
- TALLOC_FREE(frame);
return;
}
@@ -1675,7 +1670,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
data = nttrans_realloc(ppdata, sd_size);
if(data == NULL) {
- TALLOC_FREE(frame);
reply_doserror(req, ERRDOS, ERRnomem);
return;
}
@@ -1684,7 +1678,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
&blob.data, &blob.length);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(frame);
reply_nterror(req, status);
return;
}
@@ -1694,7 +1687,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
send_nt_replies(conn, req, NT_STATUS_OK, params, 4, data, (int)sd_size);
- TALLOC_FREE(frame);
return;
}
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 6aef99ff0e0..037ab633e3b 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -125,7 +125,7 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
char *saved_dir = NULL;
SMB_STRUCT_STAT sbuf;
SMB_STRUCT_STAT parent_st;
- TALLOC_CTX *ctx = talloc_stackframe();
+ TALLOC_CTX *ctx = talloc_tos();
NTSTATUS status = NT_STATUS_OK;
int ret;
@@ -135,7 +135,6 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
DEBUG(0,("change_dir_owner_to_parent: failed to stat parent "
"directory %s. Error was %s\n",
inherit_from_dir, strerror(errno) ));
- TALLOC_FREE(ctx);
return status;
}
@@ -152,7 +151,6 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
DEBUG(0,("change_dir_owner_to_parent: failed to get "
"current working directory. Error was %s\n",
strerror(errno)));
- TALLOC_FREE(ctx);
return status;
}
@@ -202,7 +200,6 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
out:
- TALLOC_FREE(ctx);
vfs_ChDir(conn,saved_dir);
return status;
}
@@ -2707,7 +2704,6 @@ NTSTATUS create_file(connection_struct *conn,
int *pinfo,
SMB_STRUCT_STAT *psbuf)
{
- TALLOC_CTX *frame = talloc_stackframe();
struct case_semantics_state *case_state = NULL;
SMB_STRUCT_STAT sbuf;
int info = FILE_WAS_OPENED;
@@ -2918,7 +2914,6 @@ NTSTATUS create_file(connection_struct *conn,
if (psbuf != NULL) {
*psbuf = sbuf;
}
- TALLOC_FREE(frame);
return NT_STATUS_OK;
fail:
@@ -2928,6 +2923,5 @@ NTSTATUS create_file(connection_struct *conn,
close_file(fsp, ERROR_CLOSE);
fsp = NULL;
}
- TALLOC_FREE(frame);
return status;
}
diff --git a/source/smbd/process.c b/source/smbd/process.c
index fe32d57ff7c..2d3cf7fbd8d 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -2071,7 +2071,7 @@ void smbd_process(void)
char *inbuf;
size_t inbuf_len;
bool encrypted = false;
- TALLOC_CTX *frame = talloc_stackframe();
+ TALLOC_CTX *frame = talloc_stackframe_pool(8192);
errno = 0;
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 65fc8181446..2588a66b8b9 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -357,7 +357,6 @@ void load_registry_shares(void)
int find_service(fstring service)
{
int iService;
- TALLOC_CTX *frame = talloc_stackframe();
all_string_sub(service,"\\","/",0);
@@ -463,8 +462,6 @@ int find_service(fstring service)
if (iService < 0)
DEBUG(3,("find_service() failed to find service %s\n", service));
- TALLOC_FREE(frame);
-
return (iService);
}
@@ -1150,20 +1147,17 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
#if SOFTLINK_OPTIMISATION
/* resolve any soft links early if possible */
if (vfs_ChDir(conn,conn->connectpath) == 0) {
- TALLOC_CTX *ctx = talloc_stackframe();
+ TALLOC_CTX *ctx = talloc_tos();
char *s = vfs_GetWd(ctx,s);
if (!s) {
*status = map_nt_error_from_unix(errno);
- TALLOC_FREE(ctx);
goto err_root_exit;
}
if (!set_conn_connectpath(conn,s)) {
*status = NT_STATUS_NO_MEMORY;
- TALLOC_FREE(ctx);
goto err_root_exit;
}
vfs_ChDir(conn,conn->connectpath);
- TALLOC_FREE(ctx);
}
#endif
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 485513c7343..ce0b239c4ec 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -297,9 +297,8 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
if (!lp_ea_support(SNUM(conn))) {
return 0;
}
- mem_ctx = talloc_init("estimate_ea_size");
+ mem_ctx = talloc_tos();
(void)get_ea_list_from_file(mem_ctx, conn, fsp, fname, &total_ea_len);
- talloc_destroy(mem_ctx);
return total_ea_len;
}
@@ -310,7 +309,7 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, const char *fname, fstring unix_ea_name)
{
size_t total_ea_len;
- TALLOC_CTX *mem_ctx = talloc_init("canonicalize_ea_name");
+ TALLOC_CTX *mem_ctx = talloc_tos();
struct ea_list *ea_list = get_ea_list_from_file(mem_ctx, conn, fsp, fname, &total_ea_len);
for (; ea_list; ea_list = ea_list->next) {
@@ -321,7 +320,6 @@ static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, con
break;
}
}
- talloc_destroy(mem_ctx);
}
/****************************************************************************
@@ -1955,9 +1953,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
out_of_space = True;
finished = False;
} else {
- TALLOC_CTX *sub_ctx = talloc_stackframe();
-
- finished = !get_lanman2_dir_entry(sub_ctx,
+ finished = !get_lanman2_dir_entry(ctx,
conn,
req->flags2,
mask,dirtype,info_level,
@@ -1966,8 +1962,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
space_remaining, &out_of_space,
&got_exact_match,
&last_entry_off, ea_list);
-
- TALLOC_FREE(sub_ctx);
}
if (finished && out_of_space)
@@ -2303,9 +2297,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
out_of_space = True;
finished = False;
} else {
- TALLOC_CTX *sub_ctx = talloc_stackframe();
-
- finished = !get_lanman2_dir_entry(sub_ctx,
+ finished = !get_lanman2_dir_entry(ctx,
conn,
req->flags2,
mask,dirtype,info_level,
@@ -2314,8 +2306,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
space_remaining, &out_of_space,
&got_exact_match,
&last_entry_off, ea_list);
-
- TALLOC_FREE(sub_ctx);
}
if (finished && out_of_space)
@@ -4759,17 +4749,12 @@ static NTSTATUS smb_info_set_ea(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
- ctx = talloc_init("SMB_INFO_SET_EA");
- if (!ctx) {
- return NT_STATUS_NO_MEMORY;
- }
+ ctx = talloc_tos();
ea_list = read_ea_list(ctx, pdata + 4, total_data - 4);
if (!ea_list) {
- talloc_destroy(ctx);
return NT_STATUS_INVALID_PARAMETER;
}
status = set_ea(conn, fsp, fname, ea_list);
- talloc_destroy(ctx);
return status;
}
diff --git a/source/smbd/vfs.c b/source/smbd/vfs.c
index 9a5e0aff60c..bb4e77ed31f 100644
--- a/source/smbd/vfs.c
+++ b/source/smbd/vfs.c
@@ -869,14 +869,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
return map_nt_error_from_unix(errno);
case ENOENT:
{
- TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ TALLOC_CTX *ctx = talloc_tos();
char *tmp_fname = NULL;
char *last_component = NULL;
/* Last component didn't exist. Remove it and try and canonicalise the directory. */
- tmp_fname = talloc_strdup(tmp_ctx, fname);
+ tmp_fname = talloc_strdup(ctx, fname);
if (!tmp_fname) {
- TALLOC_FREE(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
p = strrchr_m(tmp_fname, '/');
@@ -885,10 +884,9 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
last_component = p;
} else {
last_component = tmp_fname;
- tmp_fname = talloc_strdup(tmp_ctx,
+ tmp_fname = talloc_strdup(ctx,
".");
if (!tmp_fname) {
- TALLOC_FREE(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
}
@@ -900,15 +898,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
#endif
if (!resolved_name) {
DEBUG(3,("reduce_name: couldn't get realpath for %s\n", fname));
- TALLOC_FREE(tmp_ctx);
return map_nt_error_from_unix(errno);
}
- tmp_fname = talloc_asprintf(tmp_ctx,
+ tmp_fname = talloc_asprintf(ctx,
"%s/%s",
resolved_name,
last_component);
if (!tmp_fname) {
- TALLOC_FREE(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
#ifdef REALPATH_TAKES_NULL
@@ -922,7 +918,6 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
safe_strcpy(resolved_name_buf, tmp_fname, PATH_MAX);
resolved_name = resolved_name_buf;
#endif
- TALLOC_FREE(tmp_ctx);
break;
}
default: