diff options
author | Amitay Isaacs <amitay@gmail.com> | 2015-11-17 16:52:54 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2016-02-24 08:44:37 +0100 |
commit | cf3a0aa4102fd0e0417edfbb51785e2c04625a76 (patch) | |
tree | 2916d5f0d74e617d872c90af128322192d39104b /ctdb | |
parent | 69113fa02efb9f21592b25a46d000f7fff173453 (diff) | |
download | samba-cf3a0aa4102fd0e0417edfbb51785e2c04625a76.tar.gz |
ctdb-client: Drop TALLOC_CTX argument from ctdb_attach
The database context returned is allocated off the client and is not
allocated from user-supplied TALLOC_CTX.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/client/client.h | 2 | ||||
-rw-r--r-- | ctdb/client/client_db.c | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/ctdb/client/client.h b/ctdb/client/client.h index ec077f7b4e8..aab21d501fa 100644 --- a/ctdb/client/client.h +++ b/ctdb/client/client.h @@ -718,7 +718,7 @@ struct tevent_req *ctdb_attach_send(TALLOC_CTX *mem_ctx, bool ctdb_attach_recv(struct tevent_req *req, int *perr, struct ctdb_db_context **out); -int ctdb_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev, +int ctdb_attach(struct tevent_context *ev, struct ctdb_client_context *client, struct timeval timeout, const char *db_name, uint8_t db_flags, diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index bee148be61d..37e2ce51ec8 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -515,19 +515,26 @@ bool ctdb_attach_recv(struct tevent_req *req, int *perr, return true; } -int ctdb_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev, +int ctdb_attach(struct tevent_context *ev, struct ctdb_client_context *client, struct timeval timeout, const char *db_name, uint8_t db_flags, struct ctdb_db_context **out) { + TALLOC_CTX *mem_ctx; struct tevent_req *req; bool status; int ret; + mem_ctx = talloc_new(client); + if (mem_ctx == NULL) { + return ENOMEM; + } + req = ctdb_attach_send(mem_ctx, ev, client, timeout, db_name, db_flags); if (req == NULL) { + talloc_free(mem_ctx); return ENOMEM; } @@ -535,6 +542,7 @@ int ctdb_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev, status = ctdb_attach_recv(req, &ret, out); if (! status) { + talloc_free(mem_ctx); return ret; } @@ -544,6 +552,7 @@ int ctdb_attach(TALLOC_CTX *mem_ctx, struct tevent_context *ev, ctdb_set_call(db, CTDB_FETCH_WITH_HEADER_FUNC, ctdb_fetch_with_header_func); */ + talloc_free(mem_ctx); return 0; } |