diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-10-13 20:01:56 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-10-13 14:06:07 +0200 |
commit | 3cdb1fe4404e26ae383cfb73bfa8af36cb1d7f7c (patch) | |
tree | ed1f1f37b4ecbb887fa391da340de0c044e9dec7 /source4/lib/messaging | |
parent | 5603dab6478fbb40206a8664a308b5db5b1863e8 (diff) | |
download | samba-3cdb1fe4404e26ae383cfb73bfa8af36cb1d7f7c.tar.gz samba-3cdb1fe4404e26ae383cfb73bfa8af36cb1d7f7c.tar.bz2 samba-3cdb1fe4404e26ae383cfb73bfa8af36cb1d7f7c.zip |
s4-messaging: Pass the loadparm context, not just the messaging path
This will allow the TDB layer to get at the lp_ctx for tdb options.
Andrew Bartlett
Diffstat (limited to 'source4/lib/messaging')
-rw-r--r-- | source4/lib/messaging/messaging.c | 13 | ||||
-rw-r--r-- | source4/lib/messaging/messaging.h | 4 | ||||
-rw-r--r-- | source4/lib/messaging/pymessaging.c | 27 | ||||
-rw-r--r-- | source4/lib/messaging/tests/irpc.c | 4 | ||||
-rw-r--r-- | source4/lib/messaging/tests/messaging.c | 4 |
5 files changed, 28 insertions, 24 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 11ebf19b22..51fc8e26ed 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -34,6 +34,7 @@ #include "../lib/util/util_tdb.h" #include "cluster/cluster.h" #include "../lib/util/tevent_ntstatus.h" +#include "lib/param/param.h" /* change the message version with any incompatible changes in the protocol */ #define IMESSAGING_VERSION 1 @@ -566,7 +567,7 @@ int imessaging_cleanup(struct imessaging_context *msg) memory */ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, - const char *dir, + struct loadparm_context *lp_ctx, struct server_id server_id, struct tevent_context *ev, bool auto_remove) @@ -592,9 +593,11 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, } /* create the messaging directory if needed */ - mkdir(dir, 0700); - msg->base_path = talloc_reference(msg, dir); + msg->base_path = lpcfg_imessaging_path(msg, lp_ctx); + + mkdir(msg->base_path, 0700); + msg->path = imessaging_path(msg, server_id); msg->server_id = server_id; msg->idr = idr_init(msg); @@ -648,13 +651,13 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, A hack, for the short term until we get 'client only' messaging in place */ struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx, - const char *dir, + struct loadparm_context *lp_ctx, struct tevent_context *ev) { struct server_id id; ZERO_STRUCT(id); id.pid = random() % 0x10000000; - return imessaging_init(mem_ctx, dir, id, ev, true); + return imessaging_init(mem_ctx, lp_ctx, id, ev, true); } /* a list of registered irpc server functions diff --git a/source4/lib/messaging/messaging.h b/source4/lib/messaging/messaging.h index e51590fe74..984cd36e89 100644 --- a/source4/lib/messaging/messaging.h +++ b/source4/lib/messaging/messaging.h @@ -54,13 +54,13 @@ NTSTATUS imessaging_register(struct imessaging_context *msg, void *private_data, NTSTATUS imessaging_register_tmp(struct imessaging_context *msg, void *private_data, msg_callback_t fn, uint32_t *msg_type); struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, - const char *dir, + struct loadparm_context *lp_ctx, struct server_id server_id, struct tevent_context *ev, bool auto_remove); int imessaging_cleanup(struct imessaging_context *msg); struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx, - const char *dir, + struct loadparm_context *lp_ctx, struct tevent_context *ev); NTSTATUS imessaging_send_ptr(struct imessaging_context *msg, struct server_id server, uint32_t msg_type, void *ptr); diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 4f90db59f2..d9ad3790f9 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -64,13 +64,14 @@ typedef struct { static PyObject *py_imessaging_connect(PyTypeObject *self, PyObject *args, PyObject *kwargs) { struct tevent_context *ev; - const char *kwnames[] = { "own_id", "messaging_path", NULL }; + const char *kwnames[] = { "own_id", "lp_ctx", NULL }; PyObject *own_id = Py_None; - const char *imessaging_path = NULL; + PyObject *py_lp_ctx = Py_None; imessaging_Object *ret; + struct loadparm_context *lp_ctx; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Oz:connect", - discard_const_p(char *, kwnames), &own_id, &imessaging_path)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:connect", + discard_const_p(char *, kwnames), &own_id, &py_lp_ctx)) { return NULL; } @@ -80,15 +81,15 @@ static PyObject *py_imessaging_connect(PyTypeObject *self, PyObject *args, PyObj ret->mem_ctx = talloc_new(NULL); - ev = s4_event_context_init(ret->mem_ctx); - - if (imessaging_path == NULL) { - imessaging_path = lpcfg_imessaging_path(ret->mem_ctx, - py_default_loadparm_context(ret->mem_ctx)); - } else { - imessaging_path = talloc_strdup(ret->mem_ctx, imessaging_path); + lp_ctx = lpcfg_from_py_object(ret->mem_ctx, py_lp_ctx); + if (lp_ctx == NULL) { + PyErr_SetString(PyExc_RuntimeError, "imessaging_connect unable to interpret loadparm_context"); + talloc_free(ret->mem_ctx); + return NULL; } + ev = s4_event_context_init(ret->mem_ctx); + if (own_id != Py_None) { struct server_id server_id; @@ -96,12 +97,12 @@ static PyObject *py_imessaging_connect(PyTypeObject *self, PyObject *args, PyObj return NULL; ret->msg_ctx = imessaging_init(ret->mem_ctx, - imessaging_path, + lp_ctx, server_id, ev, true); } else { ret->msg_ctx = imessaging_client_init(ret->mem_ctx, - imessaging_path, + lp_ctx, ev); } diff --git a/source4/lib/messaging/tests/irpc.c b/source4/lib/messaging/tests/irpc.c index c94765a167..83361073b8 100644 --- a/source4/lib/messaging/tests/irpc.c +++ b/source4/lib/messaging/tests/irpc.c @@ -247,14 +247,14 @@ static bool irpc_setup(struct torture_context *tctx, void **_data) data->ev = tctx->ev; torture_assert(tctx, data->msg_ctx1 = imessaging_init(tctx, - lpcfg_imessaging_path(tctx, tctx->lp_ctx), + tctx->lp_ctx, cluster_id(0, MSG_ID1), data->ev, true), "Failed to init first messaging context"); torture_assert(tctx, data->msg_ctx2 = imessaging_init(tctx, - lpcfg_imessaging_path(tctx, tctx->lp_ctx), + tctx->lp_ctx, cluster_id(0, MSG_ID2), data->ev, true), "Failed to init second messaging context"); diff --git a/source4/lib/messaging/tests/messaging.c b/source4/lib/messaging/tests/messaging.c index c17b95e9c4..b6d1c35d1e 100644 --- a/source4/lib/messaging/tests/messaging.c +++ b/source4/lib/messaging/tests/messaging.c @@ -72,7 +72,7 @@ static bool test_ping_speed(struct torture_context *tctx) ev = tctx->ev; msg_server_ctx = imessaging_init(tctx, - lpcfg_imessaging_path(tctx, tctx->lp_ctx), cluster_id(0, 1), + tctx->lp_ctx, cluster_id(0, 1), ev, true); torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context"); @@ -81,7 +81,7 @@ static bool test_ping_speed(struct torture_context *tctx) imessaging_register_tmp(msg_server_ctx, tctx, exit_message, &msg_exit); msg_client_ctx = imessaging_init(tctx, - lpcfg_imessaging_path(tctx, tctx->lp_ctx), + tctx->lp_ctx, cluster_id(0, 2), ev, true); |