summaryrefslogtreecommitdiff
path: root/source4/smb_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-01-13 18:49:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:48 -0500
commit592fce7fb149ca5e82b14d9c8f13a4da1babe2b7 (patch)
tree6f5dba2cceef394c88ed052dab86dd355c21ec01 /source4/smb_server
parentada17c6794da2988fea7e800c60ca7e83d23eb7e (diff)
downloadsamba-592fce7fb149ca5e82b14d9c8f13a4da1babe2b7.tar.gz
samba-592fce7fb149ca5e82b14d9c8f13a4da1babe2b7.tar.bz2
samba-592fce7fb149ca5e82b14d9c8f13a4da1babe2b7.zip
r4726: - use the name tcon and tid instead of conn and cnum
- make use of talloc destructors metze (This used to be commit 8308da6ce4a95f8c10e22949ef00e9e64f2dbb85)
Diffstat (limited to 'source4/smb_server')
-rw-r--r--source4/smb_server/conn.c47
-rw-r--r--source4/smb_server/reply.c10
-rw-r--r--source4/smb_server/service.c31
-rw-r--r--source4/smb_server/smb_server.c8
-rw-r--r--source4/smb_server/smb_server.h3
5 files changed, 33 insertions, 66 deletions
diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c
index a4bf2716fe..c70ed95915 100644
--- a/source4/smb_server/conn.c
+++ b/source4/smb_server/conn.c
@@ -28,7 +28,7 @@
/****************************************************************************
init the tcon structures
****************************************************************************/
-void conn_init(struct smbsrv_connection *smb_conn)
+void smbsrv_tcon_init(struct smbsrv_connection *smb_conn)
{
smb_conn->tree.idtree_tid = idr_init(smb_conn);
}
@@ -36,18 +36,27 @@ void conn_init(struct smbsrv_connection *smb_conn)
/****************************************************************************
find a tcon given a cnum
****************************************************************************/
-struct smbsrv_tcon *conn_find(struct smbsrv_connection *smb_conn, uint_t cnum)
+struct smbsrv_tcon *smbsrv_tcon_find(struct smbsrv_connection *smb_conn, uint_t tid)
{
- return idr_find(smb_conn->tree.idtree_tid, cnum);
+ return idr_find(smb_conn->tree.idtree_tid, tid);
}
/*
destroy a connection structure
*/
-static int conn_destructor(void *ptr)
+static int smbsrv_tcon_destructor(void *ptr)
{
struct smbsrv_tcon *tcon = ptr;
- idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->cnum);
+
+
+ DEBUG(3,("%s closed connection to service %s\n",
+ socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
+ lp_servicename(SNUM(tcon))));
+
+ /* tell the ntvfs backend that we are disconnecting */
+ ntvfs_disconnect(tcon);
+
+ idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->tid);
DLIST_REMOVE(tcon->smb_conn->tree.tcons, tcon);
return 0;
}
@@ -55,7 +64,7 @@ static int conn_destructor(void *ptr)
/*
find first available connection slot
*/
-struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
+struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn)
{
struct smbsrv_tcon *tcon;
int i;
@@ -69,34 +78,12 @@ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
return NULL;
}
- tcon->cnum = i;
+ tcon->tid = i;
tcon->smb_conn = smb_conn;
- talloc_set_destructor(tcon, conn_destructor);
+ talloc_set_destructor(tcon, smbsrv_tcon_destructor);
DLIST_ADD(smb_conn->tree.tcons, tcon);
return tcon;
}
-
-/****************************************************************************
-close all tcon structures
-****************************************************************************/
-void conn_close_all(struct smbsrv_connection *smb_conn)
-{
- struct smbsrv_tcon *tcon, *next;
- for (tcon=smb_conn->tree.tcons;tcon;tcon=next) {
- next=tcon->next;
- close_cnum(tcon);
- }
-}
-
-
-/****************************************************************************
- Free a tcon structure.
-****************************************************************************/
-void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon)
-{
- talloc_free(tcon);
-}
-
diff --git a/source4/smb_server/reply.c b/source4/smb_server/reply.c
index 2dfa3726e2..2dc36a3b65 100644
--- a/source4/smb_server/reply.c
+++ b/source4/smb_server/reply.c
@@ -112,8 +112,8 @@ void reply_tcon(struct smbsrv_request *req)
req_setup_reply(req, 2, 0);
SSVAL(req->out.vwv, VWV(0), con.tcon.out.max_xmit);
- SSVAL(req->out.vwv, VWV(1), con.tcon.out.cnum);
- SSVAL(req->out.hdr, HDR_TID, req->tcon->cnum);
+ SSVAL(req->out.vwv, VWV(1), con.tcon.out.tid);
+ SSVAL(req->out.hdr, HDR_TID, req->tcon->tid);
req_send_reply(req);
}
@@ -181,8 +181,8 @@ void reply_tcon_and_X(struct smbsrv_request *req)
}
/* set the incoming and outgoing tid to the just created one */
- SSVAL(req->in.hdr, HDR_TID, con.tconx.out.cnum);
- SSVAL(req->out.hdr,HDR_TID, con.tconx.out.cnum);
+ SSVAL(req->in.hdr, HDR_TID, con.tconx.out.tid);
+ SSVAL(req->out.hdr,HDR_TID, con.tconx.out.tid);
chain_reply(req);
}
@@ -1360,7 +1360,7 @@ void reply_tdis(struct smbsrv_request *req)
return;
}
- close_cnum(req->tcon);
+ talloc_free(req->tcon);
/* construct reply */
req_setup_reply(req, 0, 0);
diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c
index 12a983e41b..1aa41d17a8 100644
--- a/source4/smb_server/service.c
+++ b/source4/smb_server/service.c
@@ -152,7 +152,7 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
return NT_STATUS_ACCESS_DENIED;
}
- tcon = conn_new(req->smb_conn);
+ tcon = smbsrv_tcon_new(req->smb_conn);
if (!tcon) {
DEBUG(0,("Couldn't find free connection.\n"));
return NT_STATUS_INSUFFICIENT_RESOURCES;
@@ -165,18 +165,16 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
status = ntvfs_init_connection(req, type);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("ntvfs_init_connection failed for service %s\n", lp_servicename(SNUM(tcon))));
- conn_free(req->smb_conn, tcon);
return status;
}
-
+
/* Invoke NTVFS connection hook */
status = ntvfs_connect(req, lp_servicename(snum));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("make_connection: NTVFS make connection failed!\n"));
- conn_free(req->smb_conn, tcon);
return status;
}
-
+
return NT_STATUS_OK;
}
@@ -229,23 +227,6 @@ static NTSTATUS make_connection(struct smbsrv_request *req,
return make_connection_snum(req, snum, type, password, dev);
}
-/****************************************************************************
-close a cnum
-****************************************************************************/
-void close_cnum(struct smbsrv_tcon *tcon)
-{
- DEBUG(3,("%s closed connection to service %s\n",
- socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
- lp_servicename(SNUM(tcon))));
-
- /* tell the ntvfs backend that we are disconnecting */
- ntvfs_disconnect(tcon);
-
- conn_free(tcon->smb_conn, tcon);
-}
-
-
-
/*
backend for tree connect call
*/
@@ -274,8 +255,8 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
}
con->tcon.out.max_xmit = req->smb_conn->negotiate.max_recv;
- con->tcon.out.cnum = req->tcon->cnum;
-
+ con->tcon.out.tid = req->tcon->tid;
+
return status;
}
@@ -285,7 +266,7 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con)
return status;
}
- con->tconx.out.cnum = req->tcon->cnum;
+ con->tconx.out.tid = req->tcon->tid;
con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type);
con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type);
con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2);
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index 0b2fe668af..ddbaf43cc9 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -39,7 +39,7 @@ BOOL req_send_oplock_break(struct smbsrv_tcon *tcon, uint16_t fnum, uint8_t leve
req_setup_reply(req, 8, 0);
SCVAL(req->out.hdr,HDR_COM,SMBlockingX);
- SSVAL(req->out.hdr,HDR_TID,tcon->cnum);
+ SSVAL(req->out.hdr,HDR_TID,tcon->tid);
SSVAL(req->out.hdr,HDR_PID,0xFFFF);
SSVAL(req->out.hdr,HDR_UID,0);
SSVAL(req->out.hdr,HDR_MID,0xFFFF);
@@ -484,7 +484,7 @@ static void switch_message(int type, struct smbsrv_request *req)
flags = smb_messages[type].flags;
- req->tcon = conn_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
+ req->tcon = smbsrv_tcon_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
if (req->session == NULL) {
/* setup the user context for this request if it
@@ -792,8 +792,6 @@ static void smbsrv_close(struct server_connection *conn, const char *reason)
DEBUG(5,("smbsrv_close: %s\n",reason));
- conn_close_all(smb_conn);
-
talloc_free(smb_conn);
return;
@@ -846,7 +844,7 @@ void smbsrv_accept(struct server_connection *conn)
srv_init_signing(smb_conn);
- conn_init(smb_conn);
+ smbsrv_tcon_init(smb_conn);
smb_conn->connection = conn;
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 8486ad0da6..8a21051b65 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -59,7 +59,8 @@ struct smbsrv_tcon {
/* the server context that this was created on */
struct smbsrv_connection *smb_conn;
- uint16_t cnum; /* an index passed over the wire (the TID) */
+ uint16_t tid; /* an index passed over the wire (the TID) */
+
int service;
BOOL read_only;
BOOL admin_user;