summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2020-02-11 21:57:42 +0100
committerBjörn Baumbach <bb@sernet.de>2020-02-18 11:38:40 +0000
commit7209357f9ba5525a207d301b299931d6bdee9c2f (patch)
treef074587895c824f4e9cc5e5d81c3ba2a74f8f16d /source3
parentdab982d88e9132cbff52db22f441c08ee59bb159 (diff)
downloadsamba-7209357f9ba5525a207d301b299931d6bdee9c2f.tar.gz
lib: Introduce messaging_context->per_process_talloc_ctx
Consolidate "msg_dgm_ref" and "msg_ctdb_ref": The only purpose of those pointers was to TALLOC_FREE() them in messaging_reinit(). We'll have a third entity to talloc_free() in the next commit, make that simpler. Bug: https://bugzilla.samba.org/show_bug.cgi?id=14281 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/messages.c84
1 files changed, 55 insertions, 29 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 065ccd3a262..b29df0a44f9 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -97,10 +97,9 @@ struct messaging_context {
struct tevent_req **waiters;
size_t num_waiters;
- void *msg_dgm_ref;
- void *msg_ctdb_ref;
-
struct server_id_db *names_db;
+
+ TALLOC_CTX *per_process_talloc_ctx;
};
static struct messaging_rec *messaging_rec_dup(TALLOC_CTX *mem_ctx,
@@ -484,6 +483,7 @@ static NTSTATUS messaging_init_internal(TALLOC_CTX *mem_ctx,
int ret;
const char *lck_path;
const char *priv_path;
+ void *ref;
bool ok;
/*
@@ -537,21 +537,28 @@ static NTSTATUS messaging_init_internal(TALLOC_CTX *mem_ctx,
ctx->event_ctx = ev;
+ ctx->per_process_talloc_ctx = talloc_new(ctx);
+ if (ctx->per_process_talloc_ctx == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
ok = messaging_register_event_context(ctx, ev);
if (!ok) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
- ctx->msg_dgm_ref = messaging_dgm_ref(ctx,
- ctx->event_ctx,
- &ctx->id.unique_id,
- priv_path,
- lck_path,
- messaging_recv_cb,
- ctx,
- &ret);
- if (ctx->msg_dgm_ref == NULL) {
+ ref = messaging_dgm_ref(
+ ctx->per_process_talloc_ctx,
+ ctx->event_ctx,
+ &ctx->id.unique_id,
+ priv_path,
+ lck_path,
+ messaging_recv_cb,
+ ctx,
+ &ret);
+ if (ref == NULL) {
DEBUG(2, ("messaging_dgm_ref failed: %s\n", strerror(ret)));
status = map_nt_error_from_unix(ret);
goto done;
@@ -560,11 +567,16 @@ static NTSTATUS messaging_init_internal(TALLOC_CTX *mem_ctx,
#ifdef CLUSTER_SUPPORT
if (lp_clustering()) {
- ctx->msg_ctdb_ref = messaging_ctdb_ref(
- ctx, ctx->event_ctx,
- lp_ctdbd_socket(), lp_ctdb_timeout(),
- ctx->id.unique_id, messaging_recv_cb, ctx, &ret);
- if (ctx->msg_ctdb_ref == NULL) {
+ ref = messaging_ctdb_ref(
+ ctx->per_process_talloc_ctx,
+ ctx->event_ctx,
+ lp_ctdbd_socket(),
+ lp_ctdb_timeout(),
+ ctx->id.unique_id,
+ messaging_recv_cb,
+ ctx,
+ &ret);
+ if (ref == NULL) {
DBG_NOTICE("messaging_ctdb_ref failed: %s\n",
strerror(ret));
status = map_nt_error_from_unix(ret);
@@ -636,9 +648,14 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
{
int ret;
char *lck_path;
+ void *ref;
+
+ TALLOC_FREE(msg_ctx->per_process_talloc_ctx);
- TALLOC_FREE(msg_ctx->msg_dgm_ref);
- TALLOC_FREE(msg_ctx->msg_ctdb_ref);
+ msg_ctx->per_process_talloc_ctx = talloc_new(msg_ctx);
+ if (msg_ctx->per_process_talloc_ctx == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
msg_ctx->id = (struct server_id) {
.pid = getpid(), .vnn = msg_ctx->id.vnn
@@ -649,23 +666,32 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx)
return NT_STATUS_NO_MEMORY;
}
- msg_ctx->msg_dgm_ref = messaging_dgm_ref(
- msg_ctx, msg_ctx->event_ctx, &msg_ctx->id.unique_id,
- private_path("msg.sock"), lck_path,
- messaging_recv_cb, msg_ctx, &ret);
+ ref = messaging_dgm_ref(
+ msg_ctx->per_process_talloc_ctx,
+ msg_ctx->event_ctx,
+ &msg_ctx->id.unique_id,
+ private_path("msg.sock"),
+ lck_path,
+ messaging_recv_cb,
+ msg_ctx,
+ &ret);
- if (msg_ctx->msg_dgm_ref == NULL) {
+ if (ref == NULL) {
DEBUG(2, ("messaging_dgm_ref failed: %s\n", strerror(ret)));
return map_nt_error_from_unix(ret);
}
if (lp_clustering()) {
- msg_ctx->msg_ctdb_ref = messaging_ctdb_ref(
- msg_ctx, msg_ctx->event_ctx,
- lp_ctdbd_socket(), lp_ctdb_timeout(),
- msg_ctx->id.unique_id, messaging_recv_cb, msg_ctx,
+ ref = messaging_ctdb_ref(
+ msg_ctx->per_process_talloc_ctx,
+ msg_ctx->event_ctx,
+ lp_ctdbd_socket(),
+ lp_ctdb_timeout(),
+ msg_ctx->id.unique_id,
+ messaging_recv_cb,
+ msg_ctx,
&ret);
- if (msg_ctx->msg_ctdb_ref == NULL) {
+ if (ref == NULL) {
DBG_NOTICE("messaging_ctdb_ref failed: %s\n",
strerror(ret));
return map_nt_error_from_unix(ret);