[SCM] Samba Shared Repository - branch v3-3-test updated - release-3-2-0pre2-2272-g559180f

Volker Lendecke vlendec at samba.org
Mon May 5 09:25:04 GMT 2008


The branch, v3-3-test has been updated
       via  559180f7d30606d1999399d954ceedc798c669a4 (commit)
      from  48fd7b3635137e2fe77c0b0413965869194421ff (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test


- Log -----------------------------------------------------------------
commit 559180f7d30606d1999399d954ceedc798c669a4
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 28 10:31:49 2008 +0200

    Remove connection_struct->mem_ctx, connection_struct is its own parent

-----------------------------------------------------------------------

Summary of changes:
 source/include/smb.h        |    1 -
 source/modules/vfs_fileid.c |    2 +-
 source/smbd/conn.c          |   17 ++-------
 source/smbd/dfree.c         |    2 +-
 source/smbd/ipc.c           |    2 +-
 source/smbd/msdfs.c         |   81 +++++++++++++++++++------------------------
 source/smbd/nttrans.c       |    2 +-
 source/smbd/posix_acls.c    |   27 +++++++-------
 source/smbd/service.c       |   12 +++---
 source/smbd/trans2.c        |    2 +-
 source/smbd/vfs.c           |    6 ++--
 11 files changed, 67 insertions(+), 87 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/smb.h b/source/include/smb.h
index ce91d81..f3295e1 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -616,7 +616,6 @@ struct share_iterator {
 
 typedef struct connection_struct {
 	struct connection_struct *next, *prev;
-	TALLOC_CTX *mem_ctx; /* long-lived memory context for things hanging off this struct. */
 	unsigned cnum; /* an index passed over the wire */
 	struct share_params *params;
 	bool force_user;
diff --git a/source/modules/vfs_fileid.c b/source/modules/vfs_fileid.c
index 5954a10..1cbd857 100644
--- a/source/modules/vfs_fileid.c
+++ b/source/modules/vfs_fileid.c
@@ -182,7 +182,7 @@ static int fileid_connect(struct vfs_handle_struct *handle,
 	struct fileid_handle_data *data;
 	const char *algorithm;
 
-	data = talloc_zero(handle->conn->mem_ctx, struct fileid_handle_data);
+	data = talloc_zero(handle->conn, struct fileid_handle_data);
 	if (!data) {
 		DEBUG(0, ("talloc_zero() failed\n"));
 		return -1;
diff --git a/source/smbd/conn.c b/source/smbd/conn.c
index 5aedadc..af18e90 100644
--- a/source/smbd/conn.c
+++ b/source/smbd/conn.c
@@ -92,7 +92,6 @@ thinking the server is still available.
 ****************************************************************************/
 connection_struct *conn_new(void)
 {
-	TALLOC_CTX *mem_ctx;
 	connection_struct *conn;
 	int i;
         int find_offset = 1;
@@ -140,18 +139,12 @@ find_again:
 		return NULL;
 	}
 
-	if ((mem_ctx=talloc_init("connection_struct"))==NULL) {
-		DEBUG(0,("talloc_init(connection_struct) failed!\n"));
-		return NULL;
-	}
-
-	if (!(conn=TALLOC_ZERO_P(mem_ctx, connection_struct)) ||
-	    !(conn->params = TALLOC_P(mem_ctx, struct share_params))) {
+	if (!(conn=TALLOC_ZERO_P(NULL, connection_struct)) ||
+	    !(conn->params = TALLOC_P(conn, struct share_params))) {
 		DEBUG(0,("TALLOC_ZERO() failed!\n"));
-		TALLOC_FREE(mem_ctx);
+		TALLOC_FREE(conn);
 		return NULL;
 	}
-	conn->mem_ctx = mem_ctx;
 	conn->cnum = i;
 
 	bitmap_set(bmap, i);
@@ -262,7 +255,6 @@ void conn_clear_vuid_cache(uint16 vuid)
 void conn_free_internal(connection_struct *conn)
 {
  	vfs_handle_struct *handle = NULL, *thandle = NULL;
- 	TALLOC_CTX *mem_ctx = NULL;
 	struct trans_state *state = NULL;
 
 	/* Free vfs_connection_struct */
@@ -292,9 +284,8 @@ void conn_free_internal(connection_struct *conn)
 	string_free(&conn->connectpath);
 	string_free(&conn->origpath);
 
-	mem_ctx = conn->mem_ctx;
 	ZERO_STRUCTP(conn);
-	talloc_destroy(mem_ctx);
+	talloc_destroy(conn);
 }
 
 /****************************************************************************
diff --git a/source/smbd/dfree.c b/source/smbd/dfree.c
index 9e7f18a..1ddcd48 100644
--- a/source/smbd/dfree.c
+++ b/source/smbd/dfree.c
@@ -206,7 +206,7 @@ SMB_BIG_UINT get_dfree_info(connection_struct *conn,
 
 	/* No cached info or time to refresh. */
 	if (!dfc) {
-		dfc = TALLOC_P(conn->mem_ctx, struct dfree_cached_info);
+		dfc = TALLOC_P(conn, struct dfree_cached_info);
 		if (!dfc) {
 			return dfree_ret;
 		}
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index 6961a5c..59a5dfd 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -525,7 +525,7 @@ void reply_trans(struct smb_request *req)
 		return;
 	}
 
-	if ((state = TALLOC_P(conn->mem_ctx, struct trans_state)) == NULL) {
+	if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
 		DEBUG(0, ("talloc failed\n"));
 		reply_nterror(req, NT_STATUS_NO_MEMORY);
 		END_PROFILE(SMBtrans);
diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c
index fb757a5..14062e1 100644
--- a/source/smbd/msdfs.c
+++ b/source/smbd/msdfs.c
@@ -175,36 +175,37 @@ static NTSTATUS parse_dfs_path(const char *pathname,
 *********************************************************/
 
 static NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
-				connection_struct *conn,
+				connection_struct **pconn,
 				int snum,
 				const char *path)
 {
+	connection_struct *conn;
 	char *connpath;
 
-	ZERO_STRUCTP(conn);
+	conn = TALLOC_ZERO_P(ctx, connection_struct);
+	if (conn == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
 
-	connpath = talloc_strdup(ctx, path);
+	connpath = talloc_strdup(conn, path);
 	if (!connpath) {
+		TALLOC_FREE(conn);
 		return NT_STATUS_NO_MEMORY;
 	}
-	connpath = talloc_string_sub(ctx,
+	connpath = talloc_string_sub(conn,
 				connpath,
 				"%S",
 				lp_servicename(snum));
 	if (!connpath) {
+		TALLOC_FREE(conn);
 		return NT_STATUS_NO_MEMORY;
 	}
 
 	/* needed for smbd_vfs_init() */
 
-	if ((conn->mem_ctx=talloc_init("connection_struct")) == NULL) {
-		DEBUG(0,("talloc_init(connection_struct) failed!\n"));
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	if (!(conn->params = TALLOC_ZERO_P(conn->mem_ctx,
-					struct share_params))) {
+	if (!(conn->params = TALLOC_ZERO_P(conn, struct share_params))) {
 		DEBUG(0, ("TALLOC failed\n"));
+		TALLOC_FREE(conn);
 		return NT_STATUS_NO_MEMORY;
 	}
 
@@ -234,6 +235,8 @@ static NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
 		return status;
 	}
 
+	*pconn = conn;
+
 	return NT_STATUS_OK;
 }
 
@@ -709,8 +712,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 			int *consumedcntp,
 			bool *self_referralp)
 {
-	struct connection_struct conns;
-	struct connection_struct *conn = &conns;
+	struct connection_struct *conn;
 	char *targetpath = NULL;
 	int snum;
 	NTSTATUS status = NT_STATUS_NOT_FOUND;
@@ -721,7 +723,6 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	ZERO_STRUCT(conns);
 	*self_referralp = False;
 
 	status = parse_dfs_path(dfs_path, False, pdp, &dummy);
@@ -825,7 +826,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 		return NT_STATUS_OK;
 	}
 
-	status = create_conn_struct(ctx, conn, snum, lp_pathname(snum));
+	status = create_conn_struct(ctx, &conn, snum, lp_pathname(snum));
 	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(pdp);
 		return status;
@@ -1251,7 +1252,7 @@ bool create_junction(TALLOC_CTX *ctx,
 
 static bool junction_to_local_path(const struct junction_map *jucn,
 				char **pp_path_out,
-				connection_struct *conn_out)
+				connection_struct **conn_out)
 {
 	int snum;
 
@@ -1265,7 +1266,7 @@ static bool junction_to_local_path(const struct junction_map *jucn,
 		return False;
 	}
 
-	*pp_path_out = talloc_asprintf(conn_out->mem_ctx,
+	*pp_path_out = talloc_asprintf(conn_out,
 			"%s/%s",
 			lp_pathname(snum),
 			jucn->volume_name);
@@ -1280,20 +1281,17 @@ bool create_msdfs_link(const struct junction_map *jucn,
 {
 	char *path = NULL;
 	char *msdfs_link = NULL;
-	connection_struct conns;
- 	connection_struct *conn = &conns;
+	connection_struct *conn;
 	int i=0;
 	bool insert_comma = False;
 	bool ret = False;
 
-	ZERO_STRUCT(conns);
-
-	if(!junction_to_local_path(jucn, &path, conn)) {
+	if(!junction_to_local_path(jucn, &path, &conn)) {
 		return False;
 	}
 
 	/* Form the msdfs_link contents */
-	msdfs_link = talloc_strdup(conn->mem_ctx, "msdfs:");
+	msdfs_link = talloc_strdup(conn, "msdfs:");
 	if (!msdfs_link) {
 		goto out;
 	}
@@ -1353,13 +1351,10 @@ out:
 bool remove_msdfs_link(const struct junction_map *jucn)
 {
 	char *path = NULL;
-	connection_struct conns;
- 	connection_struct *conn = &conns;
+	connection_struct *conn;
 	bool ret = False;
 
-	ZERO_STRUCT(conns);
-
-	if( junction_to_local_path(jucn, &path, conn) ) {
+	if( junction_to_local_path(jucn, &path, &conn) ) {
 		if( SMB_VFS_UNLINK(conn, path) == 0 ) {
 			ret = True;
 		}
@@ -1380,9 +1375,7 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
 	char *dname = NULL;
 	const char *connect_path = lp_pathname(snum);
 	const char *msdfs_proxy = lp_msdfs_proxy(snum);
-	connection_struct conn;
-
-	ZERO_STRUCT(conn);
+	connection_struct *conn;
 
 	if(*connect_path == '\0') {
 		return 0;
@@ -1406,24 +1399,24 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
 	}
 
 	/* Now enumerate all dfs links */
-	dirp = SMB_VFS_OPENDIR(&conn, ".", NULL, 0);
+	dirp = SMB_VFS_OPENDIR(conn, ".", NULL, 0);
 	if(!dirp) {
 		goto out;
 	}
 
-	while ((dname = vfs_readdirname(&conn, dirp)) != NULL) {
-		if (is_msdfs_link(&conn,
+	while ((dname = vfs_readdirname(conn, dirp)) != NULL) {
+		if (is_msdfs_link(conn,
 				dname,
 				NULL)) {
 			cnt++;
 		}
 	}
 
-	SMB_VFS_CLOSEDIR(&conn,dirp);
+	SMB_VFS_CLOSEDIR(conn,dirp);
 
 out:
 
-	conn_free_internal(&conn);
+	conn_free_internal(conn);
 	return cnt;
 }
 
@@ -1441,11 +1434,9 @@ static int form_junctions(TALLOC_CTX *ctx,
 	const char *connect_path = lp_pathname(snum);
 	char *service_name = lp_servicename(snum);
 	const char *msdfs_proxy = lp_msdfs_proxy(snum);
-	connection_struct conn;
+	connection_struct *conn;
 	struct referral *ref = NULL;
 
-	ZERO_STRUCT(conn);
-
 	if (jn_remain == 0) {
 		return 0;
 	}
@@ -1501,21 +1492,21 @@ static int form_junctions(TALLOC_CTX *ctx,
 	}
 
 	/* Now enumerate all dfs links */
-	dirp = SMB_VFS_OPENDIR(&conn, ".", NULL, 0);
+	dirp = SMB_VFS_OPENDIR(conn, ".", NULL, 0);
 	if(!dirp) {
 		goto out;
 	}
 
-	while ((dname = vfs_readdirname(&conn, dirp)) != NULL) {
+	while ((dname = vfs_readdirname(conn, dirp)) != NULL) {
 		char *link_target = NULL;
 		if (cnt >= jn_remain) {
-			SMB_VFS_CLOSEDIR(&conn,dirp);
+			SMB_VFS_CLOSEDIR(conn,dirp);
 			DEBUG(2, ("form_junctions: ran out of MSDFS "
 				"junction slots"));
 			goto out;
 		}
 		if (is_msdfs_link_internal(ctx,
-					&conn,
+					conn,
 					dname, &link_target,
 					NULL)) {
 			if (parse_msdfs_symlink(ctx,
@@ -1539,10 +1530,10 @@ static int form_junctions(TALLOC_CTX *ctx,
 out:
 
 	if (dirp) {
-		SMB_VFS_CLOSEDIR(&conn,dirp);
+		SMB_VFS_CLOSEDIR(conn,dirp);
 	}
 
-	conn_free_internal(&conn);
+	conn_free_internal(conn);
 	return cnt;
 }
 
diff --git a/source/smbd/nttrans.c b/source/smbd/nttrans.c
index ae7bd8b..ec4126c 100644
--- a/source/smbd/nttrans.c
+++ b/source/smbd/nttrans.c
@@ -2595,7 +2595,7 @@ void reply_nttrans(struct smb_request *req)
 		return;
 	}
 
-	if ((state = TALLOC_P(conn->mem_ctx, struct trans_state)) == NULL) {
+	if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
 		reply_doserror(req, ERRSRV, ERRaccess);
 		END_PROFILE(SMBnttrans);
 		return;
diff --git a/source/smbd/posix_acls.c b/source/smbd/posix_acls.c
index 732199e..33042fa 100644
--- a/source/smbd/posix_acls.c
+++ b/source/smbd/posix_acls.c
@@ -4262,30 +4262,29 @@ bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp, const char *
 SEC_DESC *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname)
 {
 	SEC_DESC *psd, *ret_sd;
-	connection_struct conn;
+	connection_struct *conn;
 	files_struct finfo;
 	struct fd_handle fh;
 
-	ZERO_STRUCT( conn );
-
-	if ( !(conn.mem_ctx = talloc_init( "novfs_get_nt_acl" )) ) {
-		DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
+	conn = TALLOC_ZERO_P(ctx, connection_struct);
+	if (conn == NULL) {
+		DEBUG(0, ("talloc failed\n"));
 		return NULL;
 	}
 
-	if (!(conn.params = TALLOC_P(conn.mem_ctx, struct share_params))) {
+	if (!(conn->params = TALLOC_P(conn, struct share_params))) {
 		DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
-		TALLOC_FREE(conn.mem_ctx);
+		TALLOC_FREE(conn);
 		return NULL;
 	}
 
-	conn.params->service = -1;
+	conn->params->service = -1;
 
-	set_conn_connectpath(&conn, "/");
+	set_conn_connectpath(conn, "/");
 
-	if (!smbd_vfs_init(&conn)) {
+	if (!smbd_vfs_init(conn)) {
 		DEBUG(0,("get_nt_acl_no_snum: Unable to create a fake connection struct!\n"));
-		conn_free_internal( &conn );
+		conn_free_internal( conn );
 		return NULL;
         }
 
@@ -4293,20 +4292,20 @@ SEC_DESC *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname)
 	ZERO_STRUCT( fh );
 
 	finfo.fnum = -1;
-	finfo.conn = &conn;
+	finfo.conn = conn;
 	finfo.fh = &fh;
 	finfo.fh->fd = -1;
 	finfo.fsp_name = CONST_DISCARD(char *,fname);
 
 	if (!NT_STATUS_IS_OK(posix_fget_nt_acl( &finfo, DACL_SECURITY_INFORMATION, &psd))) {
 		DEBUG(0,("get_nt_acl_no_snum: get_nt_acl returned zero.\n"));
-		conn_free_internal( &conn );
+		conn_free_internal( conn );
 		return NULL;
 	}
 
 	ret_sd = dup_sec_desc( ctx, psd );
 
-	conn_free_internal( &conn );
+	conn_free_internal( conn );
 
 	return ret_sd;
 }
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 33b2cb2..a405ffc 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -529,12 +529,12 @@ static NTSTATUS find_forced_user(connection_struct *conn, bool vuser_is_guest, f
 	char *fuser, *found_username;
 	NTSTATUS result;
 
-	if (!(fuser = talloc_string_sub(conn->mem_ctx, lp_force_user(snum), "%S",
+	if (!(fuser = talloc_string_sub(conn, lp_force_user(snum), "%S",
 					lp_servicename(snum)))) {
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	result = create_token_from_username(conn->mem_ctx, fuser, vuser_is_guest,
+	result = create_token_from_username(conn, fuser, vuser_is_guest,
 					    &conn->uid, &conn->gid, &found_username,
 					    &conn->nt_user_token);
 	if (!NT_STATUS_IS_OK(result)) {
@@ -697,7 +697,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
 			*status = NT_STATUS_NO_SUCH_USER;
 			return NULL;
 		}
-		status2 = create_token_from_username(conn->mem_ctx, pass->pw_name, True,
+		status2 = create_token_from_username(conn, pass->pw_name, True,
 						     &conn->uid, &conn->gid,
 						     &found_username,
 						     &conn->nt_user_token);
@@ -757,7 +757,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
 			return NULL;
 		}
 		pass = Get_Pwnam_alloc(talloc_tos(), user);
-		status2 = create_token_from_username(conn->mem_ctx, pass->pw_name, True,
+		status2 = create_token_from_username(conn, pass->pw_name, True,
 						     &conn->uid, &conn->gid,
 						     &found_username,
 						     &conn->nt_user_token);
@@ -903,7 +903,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
 					   sid_string_dbg(sid)));
 				continue;
 			}
-			if (!add_gid_to_array_unique(conn->mem_ctx, gid, &conn->groups,
+			if (!add_gid_to_array_unique(conn, gid, &conn->groups,
 						&conn->ngroups)) {
 				DEBUG(0, ("add_gid_to_array_unique failed\n"));
 				conn_free(conn);
@@ -1017,7 +1017,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
 	}
 
 	if ((!conn->printer) && (!conn->ipc)) {
-		conn->notify_ctx = notify_init(conn->mem_ctx, server_id_self(),
+		conn->notify_ctx = notify_init(conn, server_id_self(),
 					       smbd_messaging_context(),
 					       smbd_event_context(),
 					       conn);
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index e7157d0..4d60eec 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -7542,7 +7542,7 @@ void reply_trans2(struct smb_request *req)
 		}
 	}
 
-	if ((state = TALLOC_P(conn->mem_ctx, struct trans_state)) == NULL) {
+	if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
 		DEBUG(0, ("talloc failed\n"));
 		reply_nterror(req, NT_STATUS_NO_MEMORY);
 		END_PROFILE(SMBtrans2);
diff --git a/source/smbd/vfs.c b/source/smbd/vfs.c
index 33a3a43..1e137dd 100644
--- a/source/smbd/vfs.c
+++ b/source/smbd/vfs.c
@@ -177,7 +177,7 @@ bool vfs_init_custom(connection_struct *conn, const char *vfs_object)
 		goto fail;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list