diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-01-13 18:49:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:08:48 -0500 |
commit | 592fce7fb149ca5e82b14d9c8f13a4da1babe2b7 (patch) | |
tree | 6f5dba2cceef394c88ed052dab86dd355c21ec01 | |
parent | ada17c6794da2988fea7e800c60ca7e83d23eb7e (diff) | |
download | samba-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)
-rw-r--r-- | source4/include/smb_interfaces.h | 4 | ||||
-rw-r--r-- | source4/libcli/cliconnect.c | 2 | ||||
-rw-r--r-- | source4/libcli/raw/clitree.c | 6 | ||||
-rw-r--r-- | source4/libcli/util/clilsa.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/cifs/vfs_cifs.c | 2 | ||||
-rw-r--r-- | source4/smb_server/conn.c | 47 | ||||
-rw-r--r-- | source4/smb_server/reply.c | 10 | ||||
-rw-r--r-- | source4/smb_server/service.c | 31 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 8 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 3 | ||||
-rw-r--r-- | source4/torture/raw/context.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/xplogin.c | 2 |
12 files changed, 43 insertions, 76 deletions
diff --git a/source4/include/smb_interfaces.h b/source4/include/smb_interfaces.h index 1eca1fe360..5fae275f10 100644 --- a/source4/include/smb_interfaces.h +++ b/source4/include/smb_interfaces.h @@ -177,7 +177,7 @@ union smb_tcon { } in; struct { uint16_t max_xmit; - uint16_t cnum; + uint16_t tid; } out; } tcon; @@ -195,7 +195,7 @@ union smb_tcon { uint16_t options; char *dev_type; char *fs_type; - uint16_t cnum; + uint16_t tid; } out; } tconx; }; diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c index 6185ba7b7d..a0ba5ae0a1 100644 --- a/source4/libcli/cliconnect.c +++ b/source4/libcli/cliconnect.c @@ -140,7 +140,7 @@ NTSTATUS smbcli_send_tconX(struct smbcli_state *cli, const char *sharename, status = smb_tree_connect(cli->tree, mem_ctx, &tcon); - cli->tree->tid = tcon.tconx.out.cnum; + cli->tree->tid = tcon.tconx.out.tid; talloc_free(mem_ctx); diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index 777279f5f9..0f56c0fe2e 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -96,12 +96,12 @@ NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, case RAW_TCON_TCON: SMBCLI_CHECK_WCT(req, 2); parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0)); - parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1)); + parms->tcon.out.tid = SVAL(req->in.vwv, VWV(1)); break; case RAW_TCON_TCONX: ZERO_STRUCT(parms->tconx.out); - parms->tconx.out.cnum = SVAL(req->in.hdr, HDR_TID); + parms->tconx.out.tid = SVAL(req->in.hdr, HDR_TID); if (req->in.wct >= 4) { parms->tconx.out.options = SVAL(req->in.vwv, VWV(3)); } @@ -274,7 +274,7 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx, return status; } - tree->tid = tcon.tconx.out.cnum; + tree->tid = tcon.tconx.out.tid; if (tcon.tconx.out.dev_type) { tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type); } diff --git a/source4/libcli/util/clilsa.c b/source4/libcli/util/clilsa.c index c032af0abc..eac6984254 100644 --- a/source4/libcli/util/clilsa.c +++ b/source4/libcli/util/clilsa.c @@ -74,7 +74,7 @@ static NTSTATUS smblsa_connect(struct smbcli_state *cli) talloc_free(lsa); return status; } - lsa->ipc_tree->tid = tcon.tconx.out.cnum; + lsa->ipc_tree->tid = tcon.tconx.out.tid; lsa->pipe = dcerpc_pipe_init(lsa); if (lsa->pipe == NULL) { diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index 736aa3652f..2a76d245ac 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -88,7 +88,7 @@ static void cifs_socket_handler(struct event_context *ev, struct fd_event *fde, if (!smbcli_transport_process(private->transport)) { /* the connection to our server is dead */ - close_cnum(tcon); + talloc_free(tcon); } } 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; diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c index d0a948c401..20b93792df 100644 --- a/source4/torture/raw/context.c +++ b/source4/torture/raw/context.c @@ -229,7 +229,7 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_tree_connect(tree, mem_ctx, &tcon); CHECK_STATUS(status, NT_STATUS_OK); - tree->tid = tcon.tconx.out.cnum; + tree->tid = tcon.tconx.out.tid; printf("tid1=%d tid2=%d\n", cli->tree->tid, tree->tid); printf("try a tconx with a bad device type\n"); diff --git a/source4/torture/rpc/xplogin.c b/source4/torture/rpc/xplogin.c index 9002e4649a..ce16cf2b1d 100644 --- a/source4/torture/rpc/xplogin.c +++ b/source4/torture/rpc/xplogin.c @@ -163,7 +163,7 @@ static NTSTATUS anon_ipc(struct smbcli_transport *transport, return NT_STATUS_UNSUCCESSFUL; } - tree->tid = tcon.tconx.out.cnum; + tree->tid = tcon.tconx.out.tid; if (tcon.tconx.out.dev_type != NULL) tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type); |