diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-09-08 05:39:06 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:34 -0500 |
commit | 893c62d38388b20c52cf3c45069d836c46f42bd3 (patch) | |
tree | b11304934190db80fd453089a88ff18ec4728bba /source4/smb_server | |
parent | 8293df91bcec574fb4a2b290cc11dd83353264ae (diff) | |
download | samba-893c62d38388b20c52cf3c45069d836c46f42bd3.tar.gz samba-893c62d38388b20c52cf3c45069d836c46f42bd3.tar.bz2 samba-893c62d38388b20c52cf3c45069d836c46f42bd3.zip |
r2249: got rid of some more mem_ctx elements in structures
(This used to be commit 21ef338cbbe96acc8594ffc550ef60c6a40fb951)
Diffstat (limited to 'source4/smb_server')
-rw-r--r-- | source4/smb_server/conn.c | 8 | ||||
-rw-r--r-- | source4/smb_server/connection.c | 12 | ||||
-rw-r--r-- | source4/smb_server/negprot.c | 2 | ||||
-rw-r--r-- | source4/smb_server/nttrans.c | 8 | ||||
-rw-r--r-- | source4/smb_server/password.c | 2 | ||||
-rw-r--r-- | source4/smb_server/reply.c | 6 | ||||
-rw-r--r-- | source4/smb_server/request.c | 27 | ||||
-rw-r--r-- | source4/smb_server/search.c | 2 | ||||
-rw-r--r-- | source4/smb_server/service.c | 4 | ||||
-rw-r--r-- | source4/smb_server/sesssetup.c | 10 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 9 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 9 | ||||
-rw-r--r-- | source4/smb_server/trans2.c | 12 |
13 files changed, 45 insertions, 66 deletions
diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c index 197d925f34..1872d9b9d4 100644 --- a/source4/smb_server/conn.c +++ b/source4/smb_server/conn.c @@ -78,7 +78,6 @@ thinking the server is still available. ****************************************************************************/ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn) { - TALLOC_CTX *mem_ctx; struct smbsrv_tcon *tcon; int i; @@ -89,14 +88,11 @@ struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn) return NULL; } - mem_ctx = talloc_init("smbsrv_tcon[%d]", i); - - tcon = talloc_p(mem_ctx, struct smbsrv_tcon); + tcon = talloc_p(smb_conn, struct smbsrv_tcon); if (!tcon) return NULL; ZERO_STRUCTP(tcon); - tcon->mem_ctx = mem_ctx; tcon->cnum = i; tcon->smb_conn = smb_conn; @@ -152,6 +148,6 @@ void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon) bitmap_clear(smb_conn->tree.bmap, tcon->cnum); smb_conn->tree.num_open--; - talloc_destroy(tcon->mem_ctx); + talloc_destroy(tcon); } diff --git a/source4/smb_server/connection.c b/source4/smb_server/connection.c index 4cb4f2168a..4badf00ce3 100644 --- a/source4/smb_server/connection.c +++ b/source4/smb_server/connection.c @@ -110,12 +110,16 @@ BOOL claim_connection(struct smbsrv_tcon *tcon, const char *name,int max_connect struct connections_data crec; TDB_DATA kbuf, dbuf; - if (!tdb) - tdb = tdb_open_log(lock_path(tcon->mem_ctx, "connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR | O_CREAT, 0644); + if (!tdb) { + char *lpath = lock_path(tcon, "connections.tdb"); + tdb = tdb_open_log(lpath, 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR | O_CREAT, 0644); + talloc_free(lpath); + } - if (!tdb) + if (!tdb) { return False; + } /* * Enforce the max connections parameter. diff --git a/source4/smb_server/negprot.c b/source4/smb_server/negprot.c index d81900107b..fa5553b5ce 100644 --- a/source4/smb_server/negprot.c +++ b/source4/smb_server/negprot.c @@ -328,7 +328,7 @@ static void reply_nt1(struct smbsrv_request *req, uint16_t choice) return; } - nt_status = gensec_update(gensec_security, req->mem_ctx, null_data_blob, &blob); + nt_status = gensec_update(gensec_security, req, null_data_blob, &blob); if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { DEBUG(0, ("Failed to get SPNEGO to give us the first token: %s\n", nt_errstr(nt_status))); diff --git a/source4/smb_server/nttrans.c b/source4/smb_server/nttrans.c index ddae725c4b..bd8c49c594 100644 --- a/source4/smb_server/nttrans.c +++ b/source4/smb_server/nttrans.c @@ -39,10 +39,10 @@ static void nttrans_setup_reply(struct smbsrv_request *req, { trans->out.setup_count = setup_count; if (setup_count != 0) { - trans->out.setup = talloc_zero(req->mem_ctx, sizeof(uint16_t) * setup_count); + trans->out.setup = talloc_zero(req, sizeof(uint16_t) * setup_count); } - trans->out.params = data_blob_talloc(req->mem_ctx, NULL, param_size); - trans->out.data = data_blob_talloc(req->mem_ctx, NULL, data_size); + trans->out.params = data_blob_talloc(req, NULL, param_size); + trans->out.data = data_blob_talloc(req, NULL, data_size); } @@ -163,7 +163,7 @@ void reply_nttrans(struct smbsrv_request *req) } /* parse out the setup words */ - trans.in.setup = talloc(req->mem_ctx, trans.in.setup_count * sizeof(uint16_t)); + trans.in.setup = talloc(req, trans.in.setup_count * sizeof(uint16_t)); if (!trans.in.setup) { req_reply_error(req, NT_STATUS_NO_MEMORY); return; diff --git a/source4/smb_server/password.c b/source4/smb_server/password.c index 492f5700ad..c302f65980 100644 --- a/source4/smb_server/password.c +++ b/source4/smb_server/password.c @@ -101,7 +101,7 @@ uint16_t smbsrv_register_session(struct smbsrv_connection *smb_conn, { struct smbsrv_session *sess = NULL; - sess = talloc_p(smb_conn->mem_ctx, struct smbsrv_session); + sess = talloc_p(smb_conn, struct smbsrv_session); if(sess == NULL) { DEBUG(0,("talloc_p(smb_conn->mem_ctx, struct smbsrv_session) failed\n")); return UID_FIELD_INVALID; diff --git a/source4/smb_server/reply.c b/source4/smb_server/reply.c index 915919e9d6..6874b4b25b 100644 --- a/source4/smb_server/reply.c +++ b/source4/smb_server/reply.c @@ -43,7 +43,7 @@ /* useful wrapper for talloc with NO_MEMORY reply */ #define REQ_TALLOC(ptr, size) do { \ - ptr = talloc(req->mem_ctx, size); \ + ptr = talloc(req, size); \ if (!ptr) { \ req_reply_error(req, NT_STATUS_NO_MEMORY); \ return; \ @@ -678,7 +678,7 @@ void reply_readbraw(struct smbsrv_request *req) /* before calling the backend we setup the raw buffer. This * saves a copy later */ req->out.size = io.readbraw.in.maxcnt + NBT_HDR_SIZE; - req->out.buffer = talloc(req->mem_ctx, req->out.size); + req->out.buffer = talloc(req, req->out.size); if (req->out.buffer == NULL) { goto failed; } @@ -702,7 +702,7 @@ void reply_readbraw(struct smbsrv_request *req) failed: /* any failure in readbraw is equivalent to reading zero bytes */ req->out.size = 4; - req->out.buffer = talloc(req->mem_ctx, req->out.size); + req->out.buffer = talloc(req, req->out.size); SIVAL(req->out.buffer, 0, 0); /* init NBT header */ req_send_reply_nosign(req); diff --git a/source4/smb_server/request.c b/source4/smb_server/request.c index 645ea105a2..fad1d25bba 100644 --- a/source4/smb_server/request.c +++ b/source4/smb_server/request.c @@ -38,7 +38,7 @@ void req_destroy(struct smbsrv_request *req) /* ahh, its so nice to destroy a complex structure in such a * simple way! */ - talloc_destroy(req->mem_ctx); + talloc_free(req); } /**************************************************************************** @@ -48,20 +48,10 @@ such as change notify and oplock break requests struct smbsrv_request *init_smb_request(struct smbsrv_connection *smb_conn) { struct smbsrv_request *req; - TALLOC_CTX *mem_ctx; - - /* each request gets its own talloc context. The request - structure itself is also allocated inside this context, so - we need to allocate it before we construct the request - */ - mem_ctx = talloc_init("request_context[%d]", smb_conn->connection->socket->pkt_count); - if (!mem_ctx) { - return NULL; - } smb_conn->connection->socket->pkt_count++; - req = talloc(mem_ctx, sizeof(*req)); + req = talloc_p(smb_conn, struct smbsrv_request); if (!req) { return NULL; } @@ -70,7 +60,6 @@ struct smbsrv_request *init_smb_request(struct smbsrv_connection *smb_conn) /* setup the request context */ req->smb_conn = smb_conn; - req->mem_ctx = mem_ctx; return req; } @@ -123,7 +112,7 @@ void req_setup_reply(struct smbsrv_request *req, uint_t wct, uint_t buflen) /* over allocate by a small amount */ req->out.allocated = req->out.size + REQ_OVER_ALLOCATION; - req->out.buffer = talloc(req->mem_ctx, req->out.allocated); + req->out.buffer = talloc(req, req->out.allocated); if (!req->out.buffer) { smbsrv_terminate_connection(req->smb_conn, "allocation failed"); } @@ -468,7 +457,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const src_len2 += 2; } - ret = convert_string_talloc(req->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (const void **)dest); + ret = convert_string_talloc(req, CH_UTF16, CH_UNIX, src, src_len2, (const void **)dest); if (ret == -1) { *dest = NULL; @@ -515,7 +504,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons src_len2++; } - ret = convert_string_talloc(req->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (const void **)dest); + ret = convert_string_talloc(req, CH_DOS, CH_UNIX, src, src_len2, (const void **)dest); if (ret == -1) { *dest = NULL; @@ -564,7 +553,7 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const char if (PTR_DIFF(src, req->in.data) + 1 > req->in.data_size) { /* win2000 treats this as the NULL string! */ - (*dest) = talloc_strdup(req->mem_ctx, ""); + (*dest) = talloc_strdup(req, ""); return 0; } @@ -575,7 +564,7 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const char ret = req_pull_string(req, dest, src, -1, flags); if (ret == -1) { - (*dest) = talloc_strdup(req->mem_ctx, ""); + (*dest) = talloc_strdup(req, ""); return 1; } @@ -593,7 +582,7 @@ BOOL req_pull_blob(struct smbsrv_request *req, const char *src, int len, DATA_BL return False; } - (*blob) = data_blob_talloc(req->mem_ctx, src, len); + (*blob) = data_blob_talloc(req, src, len); return True; } diff --git a/source4/smb_server/search.c b/source4/smb_server/search.c index 26ad53fc80..e18ecda887 100644 --- a/source4/smb_server/search.c +++ b/source4/smb_server/search.c @@ -43,7 +43,7 @@ /* useful wrapper for talloc with NO_MEMORY reply */ #define REQ_TALLOC(ptr, size) do { \ - ptr = talloc(req->mem_ctx, size); \ + ptr = talloc(req, size); \ if (!ptr) { \ req_reply_error(req, NT_STATUS_NO_MEMORY); \ return; \ diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c index 6b7c626dd5..8741898a9c 100644 --- a/source4/smb_server/service.c +++ b/source4/smb_server/service.c @@ -311,8 +311,8 @@ NTSTATUS tcon_backend(struct smbsrv_request *req, union smb_tcon *con) } con->tconx.out.cnum = req->tcon->cnum; - con->tconx.out.dev_type = talloc_strdup(req->mem_ctx, req->tcon->dev_type); - con->tconx.out.fs_type = talloc_strdup(req->mem_ctx, req->tcon->fs_type); + 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); if (lp_msdfs_root(req->tcon->service) && lp_host_msdfs()) { con->tconx.out.options |= SMB_SHARE_IN_DFS; diff --git a/source4/smb_server/sesssetup.c b/source4/smb_server/sesssetup.c index 1c33686407..47b8082f3b 100644 --- a/source4/smb_server/sesssetup.c +++ b/source4/smb_server/sesssetup.c @@ -29,9 +29,9 @@ static void sesssetup_common_strings(struct smbsrv_request *req, char **os, char **lanman, char **domain) { - (*os) = talloc_asprintf(req->mem_ctx, "Unix"); - (*lanman) = talloc_asprintf(req->mem_ctx, "Samba %s", SAMBA_VERSION_STRING); - (*domain) = talloc_asprintf(req->mem_ctx, "%s", lp_workgroup()); + (*os) = talloc_asprintf(req, "Unix"); + (*lanman) = talloc_asprintf(req, "Samba %s", SAMBA_VERSION_STRING); + (*domain) = talloc_asprintf(req, "%s", lp_workgroup()); } @@ -205,7 +205,7 @@ static NTSTATUS sesssetup_spnego(struct smbsrv_request *req, union smb_sesssetup return NT_STATUS_ACCESS_DENIED; } - status = gensec_update(smb_sess->gensec_ctx, req->mem_ctx, sess->spnego.in.secblob, &sess->spnego.out.secblob); + status = gensec_update(smb_sess->gensec_ctx, req, sess->spnego.in.secblob, &sess->spnego.out.secblob); } else { status = gensec_server_start(&gensec_ctx); if (!NT_STATUS_IS_OK(status)) { @@ -221,7 +221,7 @@ static NTSTATUS sesssetup_spnego(struct smbsrv_request *req, union smb_sesssetup return status; } - status = gensec_update(gensec_ctx, req->mem_ctx, sess->spnego.in.secblob, &sess->spnego.out.secblob); + status = gensec_update(gensec_ctx, req, sess->spnego.in.secblob, &sess->spnego.out.secblob); } diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index d12915957e..a413a7dd4b 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -76,7 +76,7 @@ static struct smbsrv_request *receive_smb_request(struct smbsrv_connection *smb_ req->chained_fnum = -1; /* allocate the incoming buffer at the right size */ - req->in.buffer = talloc(req->mem_ctx, len + NBT_HDR_SIZE); + req->in.buffer = talloc(req, len + NBT_HDR_SIZE); /* fill in the already received header */ memcpy(req->in.buffer, header, 4); @@ -783,7 +783,7 @@ static void smbsrv_close(struct server_connection *conn, const char *reason) conn_close_all(smb_conn); - talloc_free(smb_conn->mem_ctx); + talloc_free(smb_conn); return; } @@ -822,19 +822,18 @@ void smbsrv_accept(struct server_connection *conn) mem_ctx = talloc_init("smbsrv_context"); - smb_conn = talloc_p(mem_ctx, struct smbsrv_connection); + smb_conn = talloc_p(conn, struct smbsrv_connection); if (!smb_conn) return; ZERO_STRUCTP(smb_conn); - smb_conn->mem_ctx = mem_ctx; smb_conn->pid = getpid(); sub_set_context(&smb_conn->substitute); /* set an initial client name based on its IP address. This will be replaced with the netbios name later if it gives us one */ - socket_addr = get_socket_addr(smb_conn->mem_ctx, conn->socket->fde->fd); + socket_addr = get_socket_addr(smb_conn, conn->socket->fde->fd); sub_set_remote_machine(socket_addr); /* now initialise a few default values associated with this smb socket */ diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 4ff246c415..de96fae504 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -61,9 +61,6 @@ struct smbsrv_tcon { /* the server context that this was created on */ struct smbsrv_connection *smb_conn; - /* a talloc context for all data in this structure */ - TALLOC_CTX *mem_ctx; - /* a private structure used by the active NTVFS backend */ void *ntvfs_private; @@ -86,9 +83,6 @@ struct smbsrv_tcon { /* the context for a single SMB request. This is passed to any request-context functions */ struct smbsrv_request { - /* a talloc context for the lifetime of this request */ - TALLOC_CTX *mem_ctx; - /* the server_context contains all context specific to this SMB socket */ struct smbsrv_connection *smb_conn; @@ -173,9 +167,6 @@ struct substitute_context { * information associated with a SMB server connection */ struct smbsrv_connection { - /* a talloc context for all data in this structure */ - TALLOC_CTX *mem_ctx; - /* this is the context for a SMB socket associated with the socket itself */ struct { /* the open file descriptor */ diff --git a/source4/smb_server/trans2.c b/source4/smb_server/trans2.c index c8b73ca4c6..57a385fe27 100644 --- a/source4/smb_server/trans2.c +++ b/source4/smb_server/trans2.c @@ -73,10 +73,10 @@ static void trans2_setup_reply(struct smbsrv_request *req, { trans->out.setup_count = setup_count; if (setup_count != 0) { - trans->out.setup = talloc_zero(req->mem_ctx, sizeof(uint16_t) * setup_count); + trans->out.setup = talloc_zero(req, sizeof(uint16_t) * setup_count); } - trans->out.params = data_blob_talloc(req->mem_ctx, NULL, param_size); - trans->out.data = data_blob_talloc(req->mem_ctx, NULL, data_size); + trans->out.params = data_blob_talloc(req, NULL, param_size); + trans->out.data = data_blob_talloc(req, NULL, data_size); } @@ -371,7 +371,7 @@ static NTSTATUS trans2_qfsinfo(struct smbsrv_request *req, struct smb_trans2 *tr trans2_setup_reply(req, trans, 0, 64, 0); - status = ndr_push_struct_blob(&guid_blob, req->mem_ctx, + status = ndr_push_struct_blob(&guid_blob, req, &fsinfo.objectid_information.out.guid, (ndr_push_flags_fn_t)ndr_push_GUID); if (!NT_STATUS_IS_OK(status)) { @@ -722,7 +722,7 @@ static NTSTATUS trans2_parse_sfileinfo(struct smbsrv_request *req, DATA_BLOB blob2; blob2.data = blob->data+4; blob2.length = len-4; - len = ea_pull_struct(&blob2, req->mem_ctx, &st->ea_set.in.ea); + len = ea_pull_struct(&blob2, req, &st->ea_set.in.ea); } if (len == 0) { return NT_STATUS_INVALID_PARAMETER; @@ -1275,7 +1275,7 @@ void reply_trans_generic(struct smbsrv_request *req, uint8_t command) } /* parse out the setup words */ - trans.in.setup = talloc(req->mem_ctx, trans.in.setup_count * sizeof(uint16_t)); + trans.in.setup = talloc(req, trans.in.setup_count * sizeof(uint16_t)); if (trans.in.setup_count && !trans.in.setup) { req_reply_error(req, NT_STATUS_NO_MEMORY); return; |