svn commit: samba r8964 - in trunk/source/smbd: .

jra at samba.org jra at samba.org
Tue Aug 2 23:55:53 GMT 2005


Author: jra
Date: 2005-08-02 23:55:46 +0000 (Tue, 02 Aug 2005)
New Revision: 8964

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8964

Log:
Clean up the horrid "fake conn struct" part of MSDFS.
Jeremy.

Modified:
   trunk/source/smbd/conn.c
   trunk/source/smbd/msdfs.c


Changeset:
Modified: trunk/source/smbd/conn.c
===================================================================
--- trunk/source/smbd/conn.c	2005-08-02 23:55:38 UTC (rev 8963)
+++ trunk/source/smbd/conn.c	2005-08-02 23:55:46 UTC (rev 8964)
@@ -225,10 +225,10 @@
 }
 
 /****************************************************************************
- Free a conn structure.
+ Free a conn structure - internal part.
 ****************************************************************************/
 
-void conn_free(connection_struct *conn)
+void conn_free_internal(connection_struct *conn)
 {
  	vfs_handle_struct *handle = NULL, *thandle = NULL;
  	TALLOC_CTX *mem_ctx = NULL;
@@ -243,8 +243,6 @@
 		handle = thandle;
 	}
 
-	DLIST_REMOVE(Connections, conn);
-
 	if (conn->ngroups && conn->groups) {
 		SAFE_FREE(conn->groups);
 		conn->ngroups = 0;
@@ -264,15 +262,25 @@
 	string_free(&conn->connectpath);
 	string_free(&conn->origpath);
 
-	bitmap_clear(bmap, conn->cnum);
-	num_open--;
-
 	mem_ctx = conn->mem_ctx;
 	ZERO_STRUCTP(conn);
 	talloc_destroy(mem_ctx);
 }
 
+/****************************************************************************
+ Free a conn structure.
+****************************************************************************/
 
+void conn_free(connection_struct *conn)
+{
+	DLIST_REMOVE(Connections, conn);
+
+	bitmap_clear(bmap, conn->cnum);
+	num_open--;
+
+	conn_free_internal(conn);
+}
+ 
 /****************************************************************************
 receive a smbcontrol message to forcibly unmount a share
 the message contains just a share name and all instances of that

Modified: trunk/source/smbd/msdfs.c
===================================================================
--- trunk/source/smbd/msdfs.c	2005-08-02 23:55:38 UTC (rev 8963)
+++ trunk/source/smbd/msdfs.c	2005-08-02 23:55:46 UTC (rev 8964)
@@ -133,12 +133,11 @@
 	pstring connpath;
 
 	ZERO_STRUCTP(conn);
+
 	conn->service = snum;
 	pstrcpy(connpath, path);
 	pstring_sub(connpath , "%S", lp_servicename(snum));
 
-	string_set(&conn->connectpath, connpath);
-
 	/* needed for smbd_vfs_init() */
 	
         if ( (conn->mem_ctx=talloc_init("connection_struct")) == NULL ) {
@@ -146,9 +145,11 @@
                 return False;
         }
 	
+	string_set(&conn->connectpath, connpath);
+
 	if (!smbd_vfs_init(conn)) {
 		DEBUG(0,("create_conn_struct: smbd_vfs_init failed.\n"));
-		talloc_destroy( conn->mem_ctx );
+		conn_free_internal(conn);
 		return False;
 	}
 
@@ -161,9 +162,10 @@
 	if (vfs_ChDir(conn,conn->connectpath) != 0) {
 		DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. Error was %s\n",
 					conn->connectpath, strerror(errno) ));
-		talloc_destroy( conn->mem_ctx );
+		conn_free_internal(conn);
 		return False;
 	}
+
 	return True;
 }
 
@@ -477,7 +479,7 @@
 	struct dfs_path dp;
 
 	struct connection_struct conns;
-	struct connection_struct* conn = &conns;
+	struct connection_struct *conn = &conns;
 	pstring conn_path;
 	int snum;
 	BOOL ret = False;
@@ -585,10 +587,7 @@
 
 out:
 
-	if (conn->mem_ctx) {
-		talloc_destroy( conn->mem_ctx );
-	}
-	
+	conn_free_internal(conn);
 	return ret;
 }
 
@@ -937,6 +936,8 @@
 	BOOL insert_comma = False;
 	BOOL ret = False;
 
+	ZERO_STRUCT(conns);
+
 	if(!junction_to_local_path(jucn, path, sizeof(path), conn)) {
 		return False;
 	}
@@ -981,7 +982,8 @@
 	ret = True;
 	
 out:
-	talloc_destroy( conn->mem_ctx );
+
+	conn_free_internal(conn);
 	return ret;
 }
 
@@ -992,6 +994,8 @@
  	connection_struct *conn = &conns;
 	BOOL ret = False;
 
+	ZERO_STRUCT(conns);
+
 	if( junction_to_local_path(jucn, path, sizeof(path), conn) ) {
 		if( SMB_VFS_UNLINK(conn, path) == 0 ) {
 			ret = True;
@@ -999,6 +1003,7 @@
 		talloc_destroy( conn->mem_ctx );
 	}
 
+	conn_free_internal(conn);
 	return ret;
 }
 
@@ -1012,6 +1017,8 @@
 	connection_struct conn;
 	struct referral *ref = NULL;
  
+	ZERO_STRUCT(conn);
+
 	if (jn_remain <= 0) {
 		return 0;
 	}
@@ -1078,7 +1085,8 @@
 	SMB_VFS_CLOSEDIR(&conn,dirp);
 
 out:
-	conn_free(&conn);
+
+	conn_free_internal(&conn);
 	return cnt;
 }
 



More information about the samba-cvs mailing list