[PATCH] some cleanups for notifyd
Jeremy Allison
jra at samba.org
Thu Jul 6 22:51:46 UTC 2017
On Thu, Jul 06, 2017 at 04:15:34PM +0200, Volker Lendecke via samba-technical wrote:
> Hi!
>
> The messaging_handler abstraction did not really take off. Remove it.
>
> Review appreciated!
LGTM. Pushed !
> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de
> From 56086d0c7b166e34631572200a686e321dc34584 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Fri, 16 Jun 2017 15:20:22 +0200
> Subject: [PATCH 01/10] notifyd: Only ask for messaging_ctdb_conn when
> clustering
>
> Without clustering, messaging_ctdb_conn will fail anyway.
>
> Review with "git show -b".
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 65 +++++++++++++++++++++++-------------------
> source3/smbd/server.c | 8 ++++--
> 2 files changed, 42 insertions(+), 31 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index f02ccfa..377d953 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -242,13 +242,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> #ifdef CLUSTER_SUPPORT
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_DB,
> - notifyd_got_db, state);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> + if (ctdbd_conn != NULL) {
> + subreq = messaging_handler_send(state, ev, msg_ctx,
> + MSG_SMB_NOTIFY_DB,
> + notifyd_got_db, state);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq, notifyd_handler_done, req);
> }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
> #endif
>
> names_db = messaging_names_db(msg_ctx);
> @@ -270,32 +272,37 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> }
>
> #ifdef CLUSTER_SUPPORT
> - state->log = talloc_zero(state, struct messaging_reclog);
> - if (tevent_req_nomem(state->log, req)) {
> - return tevent_req_post(req, ev);
> - }
> + if (ctdbd_conn != NULL) {
> + state->log = talloc_zero(state, struct messaging_reclog);
> + if (tevent_req_nomem(state->log, req)) {
> + return tevent_req_post(req, ev);
> + }
>
> - subreq = notifyd_broadcast_reclog_send(
> - state->log, ev, ctdbd_conn, messaging_server_id(msg_ctx),
> - state->log);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq, notifyd_broadcast_reclog_finished,
> - req);
> + subreq = notifyd_broadcast_reclog_send(
> + state->log, ev, ctdbd_conn,
> + messaging_server_id(msg_ctx),
> + state->log);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq,
> + notifyd_broadcast_reclog_finished,
> + req);
>
> - subreq = notifyd_clean_peers_send(state, ev, state);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> - req);
> + subreq = notifyd_clean_peers_send(state, ev, state);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> + req);
>
> - ret = register_with_ctdbd(ctdbd_conn, CTDB_SRVID_SAMBA_NOTIFY_PROXY,
> - notifyd_snoop_broadcast, state);
> - if (ret != 0) {
> - tevent_req_error(req, ret);
> - return tevent_req_post(req, ev);
> + ret = register_with_ctdbd(ctdbd_conn,
> + CTDB_SRVID_SAMBA_NOTIFY_PROXY,
> + notifyd_snoop_broadcast, state);
> + if (ret != 0) {
> + tevent_req_error(req, ret);
> + return tevent_req_post(req, ev);
> + }
> }
> #endif
>
> diff --git a/source3/smbd/server.c b/source3/smbd/server.c
> index fa13dbc..e18a4e5 100644
> --- a/source3/smbd/server.c
> +++ b/source3/smbd/server.c
> @@ -334,6 +334,7 @@ static struct tevent_req *notifyd_req(struct messaging_context *msg_ctx,
> struct tevent_req *req;
> sys_notify_watch_fn sys_notify_watch = NULL;
> struct sys_notify_context *sys_notify_ctx = NULL;
> + struct ctdbd_connection *ctdbd_conn = NULL;
>
> if (lp_kernel_change_notify()) {
>
> @@ -358,8 +359,11 @@ static struct tevent_req *notifyd_req(struct messaging_context *msg_ctx,
> }
> }
>
> - req = notifyd_send(msg_ctx, ev, msg_ctx,
> - messaging_ctdbd_connection(),
> + if (lp_clustering()) {
> + ctdbd_conn = messaging_ctdbd_connection();
> + }
> +
> + req = notifyd_send(msg_ctx, ev, msg_ctx, ctdbd_conn,
> sys_notify_watch, sys_notify_ctx);
> if (req == NULL) {
> TALLOC_FREE(sys_notify_ctx);
> --
> 2.1.4
>
>
> From b89e869834b0c555a917f8f8630959ea4ccb4c2f Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Wed, 5 Jul 2017 09:34:51 +0200
> Subject: [PATCH 02/10] notifyd: Consolidate two #ifdef CLUSTER into one
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index 377d953..fec9a5b 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -241,18 +241,6 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> -#ifdef CLUSTER_SUPPORT
> - if (ctdbd_conn != NULL) {
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_DB,
> - notifyd_got_db, state);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
> - }
> -#endif
> -
> names_db = messaging_names_db(msg_ctx);
>
> ret = server_id_db_set_exclusive(names_db, "notify-daemon");
> @@ -273,6 +261,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
>
> #ifdef CLUSTER_SUPPORT
> if (ctdbd_conn != NULL) {
> +
> + subreq = messaging_handler_send(state, ev, msg_ctx,
> + MSG_SMB_NOTIFY_DB,
> + notifyd_got_db, state);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq, notifyd_handler_done, req);
> +
> state->log = talloc_zero(state, struct messaging_reclog);
> if (tevent_req_nomem(state->log, req)) {
> return tevent_req_post(req, ev);
> --
> 2.1.4
>
>
> From 7df09fe4e9440a97b62b6517d24a542fc47bb624 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Wed, 5 Jul 2017 09:37:14 +0200
> Subject: [PATCH 03/10] notifyd: Avoid an if-expression
>
> Best reviewed with "git show -b -U10"
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 69 ++++++++++++++++++++----------------------
> 1 file changed, 33 insertions(+), 36 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index fec9a5b..2b70371 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -260,46 +260,43 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> }
>
> #ifdef CLUSTER_SUPPORT
> - if (ctdbd_conn != NULL) {
> -
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_DB,
> - notifyd_got_db, state);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
> + subreq = messaging_handler_send(state, ev, msg_ctx,
> + MSG_SMB_NOTIFY_DB,
> + notifyd_got_db, state);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> - state->log = talloc_zero(state, struct messaging_reclog);
> - if (tevent_req_nomem(state->log, req)) {
> - return tevent_req_post(req, ev);
> - }
> + state->log = talloc_zero(state, struct messaging_reclog);
> + if (tevent_req_nomem(state->log, req)) {
> + return tevent_req_post(req, ev);
> + }
>
> - subreq = notifyd_broadcast_reclog_send(
> - state->log, ev, ctdbd_conn,
> - messaging_server_id(msg_ctx),
> - state->log);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq,
> - notifyd_broadcast_reclog_finished,
> - req);
> + subreq = notifyd_broadcast_reclog_send(
> + state->log, ev, ctdbd_conn,
> + messaging_server_id(msg_ctx),
> + state->log);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq,
> + notifyd_broadcast_reclog_finished,
> + req);
>
> - subreq = notifyd_clean_peers_send(state, ev, state);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> - req);
> + subreq = notifyd_clean_peers_send(state, ev, state);
> + if (tevent_req_nomem(subreq, req)) {
> + return tevent_req_post(req, ev);
> + }
> + tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> + req);
>
> - ret = register_with_ctdbd(ctdbd_conn,
> - CTDB_SRVID_SAMBA_NOTIFY_PROXY,
> - notifyd_snoop_broadcast, state);
> - if (ret != 0) {
> - tevent_req_error(req, ret);
> - return tevent_req_post(req, ev);
> - }
> + ret = register_with_ctdbd(ctdbd_conn,
> + CTDB_SRVID_SAMBA_NOTIFY_PROXY,
> + notifyd_snoop_broadcast, state);
> + if (ret != 0) {
> + tevent_req_error(req, ret);
> + return tevent_req_post(req, ev);
> }
> #endif
>
> --
> 2.1.4
>
>
> From cb2f6ea2e9282cd17bb45dbd63e97be9cc232730 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 08:38:19 +0200
> Subject: [PATCH 04/10] messaging: make messaging_rec_create public
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/include/messages.h | 5 +++++
> source3/lib/messages.c | 2 +-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/source3/include/messages.h b/source3/include/messages.h
> index 806f7b0..46dc6c0 100644
> --- a/source3/include/messages.h
> +++ b/source3/include/messages.h
> @@ -145,6 +145,11 @@ int messaging_cleanup(struct messaging_context *msg_ctx, pid_t pid);
>
> bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg);
>
> +struct messaging_rec *messaging_rec_create(
> + TALLOC_CTX *mem_ctx, struct server_id src, struct server_id dst,
> + uint32_t msg_type, const struct iovec *iov, int iovlen,
> + const int *fds, size_t num_fds);
> +
> #include "librpc/gen_ndr/ndr_messaging.h"
>
> #endif
> diff --git a/source3/lib/messages.c b/source3/lib/messages.c
> index b0edb30..da13a1e 100644
> --- a/source3/lib/messages.c
> +++ b/source3/lib/messages.c
> @@ -110,7 +110,7 @@ static void ping_message(struct messaging_context *msg_ctx,
> messaging_send(msg_ctx, src, MSG_PONG, data);
> }
>
> -static struct messaging_rec *messaging_rec_create(
> +struct messaging_rec *messaging_rec_create(
> TALLOC_CTX *mem_ctx, struct server_id src, struct server_id dst,
> uint32_t msg_type, const struct iovec *iov, int iovlen,
> const int *fds, size_t num_fds)
> --
> 2.1.4
>
>
> From 586f4c233061b29f9855160b52b5777a0f1aa803 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 08:38:53 +0200
> Subject: [PATCH 05/10] notifyd: Use messaging_register for
> MSG_SMB_NOTIFY_REC_CHANGE
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 73 ++++++++++++++++++++++++------------------
> 1 file changed, 41 insertions(+), 32 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index 2b70371..e078b40 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -32,6 +32,7 @@
> #include "notifyd.h"
> #include "lib/util/server_id_db.h"
> #include "lib/util/tevent_unix.h"
> +#include "lib/util/tevent_ntstatus.h"
> #include "ctdbd_conn.h"
> #include "ctdb_srvids.h"
> #include "server_id_db_util.h"
> @@ -122,9 +123,9 @@ struct notifyd_peer {
> time_t last_broadcast;
> };
>
> -static bool notifyd_rec_change(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data);
> +static void notifyd_rec_change(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data);
> static bool notifyd_trigger(struct messaging_context *msg_ctx,
> struct messaging_rec **prec,
> void *private_data);
> @@ -195,6 +196,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> struct tevent_req *req, *subreq;
> struct notifyd_state *state;
> struct server_id_db *names_db;
> + NTSTATUS status;
> int ret;
>
> req = tevent_req_create(mem_ctx, &state, struct notifyd_state);
> @@ -217,19 +219,17 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> return tevent_req_post(req, ev);
> }
>
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_REC_CHANGE,
> - notifyd_rec_change, state);
> - if (tevent_req_nomem(subreq, req)) {
> + status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_REC_CHANGE,
> + notifyd_rec_change);
> + if (tevent_req_nterror(req, status)) {
> return tevent_req_post(req, ev);
> }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> subreq = messaging_handler_send(state, ev, msg_ctx,
> MSG_SMB_NOTIFY_TRIGGER,
> notifyd_trigger, state);
> if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> @@ -237,7 +237,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> MSG_SMB_NOTIFY_GET_DB,
> notifyd_get_db, state);
> if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> @@ -248,7 +248,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> DEBUG(10, ("%s: server_id_db_add failed: %s\n",
> __func__, strerror(ret)));
> tevent_req_error(req, ret);
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
>
> if (ctdbd_conn == NULL) {
> @@ -264,13 +264,13 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> MSG_SMB_NOTIFY_DB,
> notifyd_got_db, state);
> if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> state->log = talloc_zero(state, struct messaging_reclog);
> if (tevent_req_nomem(state->log, req)) {
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
>
> subreq = notifyd_broadcast_reclog_send(
> @@ -278,7 +278,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> messaging_server_id(msg_ctx),
> state->log);
> if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
> tevent_req_set_callback(subreq,
> notifyd_broadcast_reclog_finished,
> @@ -286,7 +286,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
>
> subreq = notifyd_clean_peers_send(state, ev, state);
> if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
> tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> req);
> @@ -296,11 +296,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> notifyd_snoop_broadcast, state);
> if (ret != 0) {
> tevent_req_error(req, ret);
> - return tevent_req_post(req, ev);
> + goto deregister_rec_change;
> }
> #endif
>
> return req;
> +
> +deregister_rec_change:
> + messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_REC_CHANGE, state);
> + return tevent_req_post(req, ev);
> }
>
> static void notifyd_handler_done(struct tevent_req *subreq)
> @@ -568,40 +572,38 @@ static bool notifyd_parse_rec_change(uint8_t *buf, size_t bufsize,
> return true;
> }
>
> -static bool notifyd_rec_change(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data)
> +static void notifyd_rec_change(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data)
> {
> struct notifyd_state *state = talloc_get_type_abort(
> private_data, struct notifyd_state);
> struct server_id_buf idbuf;
> - struct messaging_rec *rec = *prec;
> struct notify_rec_change_msg *msg;
> size_t pathlen;
> bool ok;
>
> - DEBUG(10, ("%s: Got %d bytes from %s\n", __func__,
> - (unsigned)rec->buf.length,
> - server_id_str_buf(rec->src, &idbuf)));
> + DBG_DEBUG("Got %zu bytes from %s\n", data->length,
> + server_id_str_buf(src, &idbuf));
>
> - ok = notifyd_parse_rec_change(rec->buf.data, rec->buf.length,
> + ok = notifyd_parse_rec_change(data->data, data->length,
> &msg, &pathlen);
> if (!ok) {
> - return true;
> + return;
> }
>
> ok = notifyd_apply_rec_change(
> - &rec->src, msg->path, pathlen, &msg->instance,
> + &src, msg->path, pathlen, &msg->instance,
> state->entries, state->sys_notify_watch, state->sys_notify_ctx,
> state->msg_ctx);
> if (!ok) {
> DEBUG(1, ("%s: notifyd_apply_rec_change failed, ignoring\n",
> __func__));
> - return true;
> + return;
> }
>
> if ((state->log == NULL) || (state->ctdbd_conn == NULL)) {
> - return true;
> + return;
> }
>
> #ifdef CLUSTER_SUPPORT
> @@ -609,6 +611,7 @@ static bool notifyd_rec_change(struct messaging_context *msg_ctx,
>
> struct messaging_rec **tmp;
> struct messaging_reclog *log;
> + struct iovec iov = { .iov_base = data->data, .iov_len = data->length };
>
> log = state->log;
>
> @@ -616,11 +619,19 @@ static bool notifyd_rec_change(struct messaging_context *msg_ctx,
> log->num_recs+1);
> if (tmp == NULL) {
> DEBUG(1, ("%s: talloc_realloc failed, ignoring\n", __func__));
> - return true;
> + return;
> }
> log->recs = tmp;
>
> - log->recs[log->num_recs] = talloc_move(log->recs, prec);
> + log->recs[log->num_recs] = messaging_rec_create(
> + log->recs, src, messaging_server_id(msg_ctx),
> + msg_type, &iov, 1, NULL, 0);
> +
> + if (log->recs[log->num_recs] == NULL) {
> + DBG_WARNING("messaging_rec_create failed, ignoring\n");
> + return;
> + }
> +
> log->num_recs += 1;
>
> if (log->num_recs >= 100) {
> @@ -633,8 +644,6 @@ static bool notifyd_rec_change(struct messaging_context *msg_ctx,
>
> }
> #endif
> -
> - return true;
> }
>
> struct notifyd_trigger_state {
> --
> 2.1.4
>
>
> From 8fba4ab707e412915b9c3e93d7446167cfaf3450 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 08:45:17 +0200
> Subject: [PATCH 06/10] notifyd: Use messaging_register for
> MSG_SMB_NOTIFY_TRIGGER
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 61 ++++++++++++++++++++----------------------
> 1 file changed, 29 insertions(+), 32 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index e078b40..99539f8 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -126,9 +126,9 @@ struct notifyd_peer {
> static void notifyd_rec_change(struct messaging_context *msg_ctx,
> void *private_data, uint32_t msg_type,
> struct server_id src, DATA_BLOB *data);
> -static bool notifyd_trigger(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data);
> +static void notifyd_trigger(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data);
> static bool notifyd_get_db(struct messaging_context *msg_ctx,
> struct messaging_rec **prec,
> void *private_data);
> @@ -225,19 +225,17 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> return tevent_req_post(req, ev);
> }
>
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_TRIGGER,
> - notifyd_trigger, state);
> - if (tevent_req_nomem(subreq, req)) {
> + status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_TRIGGER,
> + notifyd_trigger);
> + if (tevent_req_nterror(req, status)) {
> goto deregister_rec_change;
> }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> subreq = messaging_handler_send(state, ev, msg_ctx,
> MSG_SMB_NOTIFY_GET_DB,
> notifyd_get_db, state);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> @@ -248,7 +246,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> DEBUG(10, ("%s: server_id_db_add failed: %s\n",
> __func__, strerror(ret)));
> tevent_req_error(req, ret);
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
>
> if (ctdbd_conn == NULL) {
> @@ -264,13 +262,13 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> MSG_SMB_NOTIFY_DB,
> notifyd_got_db, state);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> state->log = talloc_zero(state, struct messaging_reclog);
> if (tevent_req_nomem(state->log, req)) {
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
>
> subreq = notifyd_broadcast_reclog_send(
> @@ -278,7 +276,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> messaging_server_id(msg_ctx),
> state->log);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
> tevent_req_set_callback(subreq,
> notifyd_broadcast_reclog_finished,
> @@ -286,7 +284,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
>
> subreq = notifyd_clean_peers_send(state, ev, state);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
> tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> req);
> @@ -296,12 +294,14 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> notifyd_snoop_broadcast, state);
> if (ret != 0) {
> tevent_req_error(req, ret);
> - goto deregister_rec_change;
> + goto deregister_trigger;
> }
> #endif
>
> return req;
>
> +deregister_trigger:
> + messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_TRIGGER, state);
> deregister_rec_change:
> messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_REC_CHANGE, state);
> return tevent_req_post(req, ev);
> @@ -656,34 +656,33 @@ struct notifyd_trigger_state {
> static void notifyd_trigger_parser(TDB_DATA key, TDB_DATA data,
> void *private_data);
>
> -static bool notifyd_trigger(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data)
> +static void notifyd_trigger(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data)
> {
> struct notifyd_state *state = talloc_get_type_abort(
> private_data, struct notifyd_state);
> struct server_id my_id = messaging_server_id(msg_ctx);
> - struct messaging_rec *rec = *prec;
> struct notifyd_trigger_state tstate;
> const char *path;
> const char *p, *next_p;
>
> - if (rec->buf.length < offsetof(struct notify_trigger_msg, path) + 1) {
> - DEBUG(1, ("message too short, ignoring: %u\n",
> - (unsigned)rec->buf.length));
> - return true;
> + if (data->length < offsetof(struct notify_trigger_msg, path) + 1) {
> + DBG_WARNING("message too short, ignoring: %zu\n",
> + data->length);
> + return;
> }
> - if (rec->buf.data[rec->buf.length-1] != 0) {
> + if (data->data[data->length-1] != 0) {
> DEBUG(1, ("%s: path not 0-terminated, ignoring\n", __func__));
> - return true;
> + return;
> }
>
> tstate.msg_ctx = msg_ctx;
>
> - tstate.covered_by_sys_notify = (rec->src.vnn == my_id.vnn);
> - tstate.covered_by_sys_notify &= !server_id_equal(&rec->src, &my_id);
> + tstate.covered_by_sys_notify = (src.vnn == my_id.vnn);
> + tstate.covered_by_sys_notify &= !server_id_equal(&src, &my_id);
>
> - tstate.msg = (struct notify_trigger_msg *)rec->buf.data;
> + tstate.msg = (struct notify_trigger_msg *)data->data;
> path = tstate.msg->path;
>
> DEBUG(10, ("%s: Got trigger_msg action=%u, filter=%u, path=%s\n",
> @@ -693,7 +692,7 @@ static bool notifyd_trigger(struct messaging_context *msg_ctx,
> if (path[0] != '/') {
> DEBUG(1, ("%s: path %s does not start with /, ignoring\n",
> __func__, path));
> - return true;
> + return;
> }
>
> for (p = strchr(path+1, '/'); p != NULL; p = next_p) {
> @@ -717,7 +716,7 @@ static bool notifyd_trigger(struct messaging_context *msg_ctx,
> continue;
> }
>
> - if (rec->src.vnn != my_id.vnn) {
> + if (src.vnn != my_id.vnn) {
> continue;
> }
>
> @@ -732,8 +731,6 @@ static bool notifyd_trigger(struct messaging_context *msg_ctx,
> notifyd_trigger_parser, &tstate);
> }
> }
> -
> - return true;
> }
>
> static void notifyd_send_delete(struct messaging_context *msg_ctx,
> --
> 2.1.4
>
>
> From 305ef3becc6847fdd9007be0c0901ac0246937bc Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 08:48:45 +0200
> Subject: [PATCH 07/10] notifyd: Use messaging_register for
> MSG_SMB_NOTIFY_GET_DB
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 47 ++++++++++++++++++++----------------------
> 1 file changed, 22 insertions(+), 25 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index 99539f8..cd98ff5 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -129,9 +129,9 @@ static void notifyd_rec_change(struct messaging_context *msg_ctx,
> static void notifyd_trigger(struct messaging_context *msg_ctx,
> void *private_data, uint32_t msg_type,
> struct server_id src, DATA_BLOB *data);
> -static bool notifyd_get_db(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data);
> +static void notifyd_get_db(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data);
>
> #ifdef CLUSTER_SUPPORT
> static bool notifyd_got_db(struct messaging_context *msg_ctx,
> @@ -231,13 +231,11 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> goto deregister_rec_change;
> }
>
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_GET_DB,
> - notifyd_get_db, state);
> - if (tevent_req_nomem(subreq, req)) {
> + status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_GET_DB,
> + notifyd_get_db);
> + if (tevent_req_nterror(req, status)) {
> goto deregister_trigger;
> }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> names_db = messaging_names_db(msg_ctx);
>
> @@ -246,7 +244,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> DEBUG(10, ("%s: server_id_db_add failed: %s\n",
> __func__, strerror(ret)));
> tevent_req_error(req, ret);
> - goto deregister_trigger;
> + goto deregister_get_db;
> }
>
> if (ctdbd_conn == NULL) {
> @@ -262,13 +260,13 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> MSG_SMB_NOTIFY_DB,
> notifyd_got_db, state);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_trigger;
> + goto deregister_get_db;
> }
> tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> state->log = talloc_zero(state, struct messaging_reclog);
> if (tevent_req_nomem(state->log, req)) {
> - goto deregister_trigger;
> + goto deregister_get_db;
> }
>
> subreq = notifyd_broadcast_reclog_send(
> @@ -276,7 +274,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> messaging_server_id(msg_ctx),
> state->log);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_trigger;
> + goto deregister_get_db;
> }
> tevent_req_set_callback(subreq,
> notifyd_broadcast_reclog_finished,
> @@ -284,7 +282,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
>
> subreq = notifyd_clean_peers_send(state, ev, state);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_trigger;
> + goto deregister_get_db;
> }
> tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> req);
> @@ -294,12 +292,14 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> notifyd_snoop_broadcast, state);
> if (ret != 0) {
> tevent_req_error(req, ret);
> - goto deregister_trigger;
> + goto deregister_get_db;
> }
> #endif
>
> return req;
>
> +deregister_get_db:
> + messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_GET_DB, state);
> deregister_trigger:
> messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_TRIGGER, state);
> deregister_rec_change:
> @@ -852,13 +852,12 @@ static void notifyd_send_delete(struct messaging_context *msg_ctx,
> }
> }
>
> -static bool notifyd_get_db(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data)
> +static void notifyd_get_db(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data)
> {
> struct notifyd_state *state = talloc_get_type_abort(
> private_data, struct notifyd_state);
> - struct messaging_rec *rec = *prec;
> struct server_id_buf id1, id2;
> NTSTATUS status;
> uint64_t rec_index = UINT64_MAX;
> @@ -869,11 +868,11 @@ static bool notifyd_get_db(struct messaging_context *msg_ctx,
>
> dbsize = dbwrap_marshall(state->entries, NULL, 0);
>
> - buf = talloc_array(rec, uint8_t, dbsize);
> + buf = talloc_array(talloc_tos(), uint8_t, dbsize);
> if (buf == NULL) {
> DEBUG(1, ("%s: talloc_array(%ju) failed\n",
> __func__, (uintmax_t)dbsize));
> - return true;
> + return;
> }
>
> dbsize = dbwrap_marshall(state->entries, buf, dbsize);
> @@ -883,7 +882,7 @@ static bool notifyd_get_db(struct messaging_context *msg_ctx,
> (uintmax_t)talloc_get_size(buf),
> (uintmax_t)dbsize));
> TALLOC_FREE(buf);
> - return true;
> + return;
> }
>
> if (state->log != NULL) {
> @@ -899,17 +898,15 @@ static bool notifyd_get_db(struct messaging_context *msg_ctx,
> DEBUG(10, ("%s: Sending %ju bytes to %s->%s\n", __func__,
> (uintmax_t)iov_buflen(iov, ARRAY_SIZE(iov)),
> server_id_str_buf(messaging_server_id(msg_ctx), &id1),
> - server_id_str_buf(rec->src, &id2)));
> + server_id_str_buf(src, &id2)));
>
> - status = messaging_send_iov(msg_ctx, rec->src, MSG_SMB_NOTIFY_DB,
> + status = messaging_send_iov(msg_ctx, src, MSG_SMB_NOTIFY_DB,
> iov, ARRAY_SIZE(iov), NULL, 0);
> TALLOC_FREE(buf);
> if (!NT_STATUS_IS_OK(status)) {
> DEBUG(1, ("%s: messaging_send_iov failed: %s\n",
> __func__, nt_errstr(status)));
> }
> -
> - return true;
> }
>
> #ifdef CLUSTER_SUPPORT
> --
> 2.1.4
>
>
> From 56eece38e630137e9de28672e35b6fb295af9584 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 08:56:35 +0200
> Subject: [PATCH 08/10] notifyd: Use messaging_register for MSG_SMB_NOTIFY_DB
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 71 +++++++++++++++++++++---------------------
> 1 file changed, 36 insertions(+), 35 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index cd98ff5..bc69485 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -134,9 +134,9 @@ static void notifyd_get_db(struct messaging_context *msg_ctx,
> struct server_id src, DATA_BLOB *data);
>
> #ifdef CLUSTER_SUPPORT
> -static bool notifyd_got_db(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data);
> +static void notifyd_got_db(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data);
> static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn,
> struct server_id src,
> struct messaging_reclog *log);
> @@ -193,7 +193,10 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> sys_notify_watch_fn sys_notify_watch,
> struct sys_notify_context *sys_notify_ctx)
> {
> - struct tevent_req *req, *subreq;
> + struct tevent_req *req;
> +#ifdef CLUSTER_SUPPORT
> + struct tevent_req *subreq;
> +#endif
> struct notifyd_state *state;
> struct server_id_db *names_db;
> NTSTATUS status;
> @@ -256,17 +259,15 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> }
>
> #ifdef CLUSTER_SUPPORT
> - subreq = messaging_handler_send(state, ev, msg_ctx,
> - MSG_SMB_NOTIFY_DB,
> - notifyd_got_db, state);
> - if (tevent_req_nomem(subreq, req)) {
> + status = messaging_register(msg_ctx, state, MSG_SMB_NOTIFY_DB,
> + notifyd_got_db);
> + if (tevent_req_nterror(req, status)) {
> goto deregister_get_db;
> }
> - tevent_req_set_callback(subreq, notifyd_handler_done, req);
>
> state->log = talloc_zero(state, struct messaging_reclog);
> if (tevent_req_nomem(state->log, req)) {
> - goto deregister_get_db;
> + goto deregister_db;
> }
>
> subreq = notifyd_broadcast_reclog_send(
> @@ -274,7 +275,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> messaging_server_id(msg_ctx),
> state->log);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_get_db;
> + goto deregister_db;
> }
> tevent_req_set_callback(subreq,
> notifyd_broadcast_reclog_finished,
> @@ -282,7 +283,7 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
>
> subreq = notifyd_clean_peers_send(state, ev, state);
> if (tevent_req_nomem(subreq, req)) {
> - goto deregister_get_db;
> + goto deregister_db;
> }
> tevent_req_set_callback(subreq, notifyd_clean_peers_finished,
> req);
> @@ -292,12 +293,16 @@ struct tevent_req *notifyd_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> notifyd_snoop_broadcast, state);
> if (ret != 0) {
> tevent_req_error(req, ret);
> - goto deregister_get_db;
> + goto deregister_db;
> }
> #endif
>
> return req;
>
> +#ifdef CLUSTER_SUPPORT
> +deregister_db:
> + messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_DB, state);
> +#endif
> deregister_get_db:
> messaging_deregister(msg_ctx, MSG_SMB_NOTIFY_GET_DB, state);
> deregister_trigger:
> @@ -914,13 +919,12 @@ static void notifyd_get_db(struct messaging_context *msg_ctx,
> static int notifyd_add_proxy_syswatches(struct db_record *rec,
> void *private_data);
>
> -static bool notifyd_got_db(struct messaging_context *msg_ctx,
> - struct messaging_rec **prec,
> - void *private_data)
> +static void notifyd_got_db(struct messaging_context *msg_ctx,
> + void *private_data, uint32_t msg_type,
> + struct server_id src, DATA_BLOB *data)
> {
> struct notifyd_state *state = talloc_get_type_abort(
> private_data, struct notifyd_state);
> - struct messaging_rec *rec = *prec;
> struct notifyd_peer *p = NULL;
> struct server_id_buf idbuf;
> NTSTATUS status;
> @@ -928,52 +932,49 @@ static bool notifyd_got_db(struct messaging_context *msg_ctx,
> size_t i;
>
> for (i=0; i<state->num_peers; i++) {
> - if (server_id_equal(&rec->src, &state->peers[i]->pid)) {
> + if (server_id_equal(&src, &state->peers[i]->pid)) {
> p = state->peers[i];
> break;
> }
> }
>
> if (p == NULL) {
> - DEBUG(10, ("%s: Did not find peer for db from %s\n",
> - __func__, server_id_str_buf(rec->src, &idbuf)));
> - return true;
> + DBG_DEBUG("Did not find peer for db from %s\n",
> + server_id_str_buf(src, &idbuf));
> + return;
> }
>
> - if (rec->buf.length < 8) {
> - DEBUG(10, ("%s: Got short db length %u from %s\n", __func__,
> - (unsigned)rec->buf.length,
> - server_id_str_buf(rec->src, &idbuf)));
> + if (data->length < 8) {
> + DBG_DEBUG("Got short db length %zu from %s\n", data->length,
> + server_id_str_buf(src, &idbuf));
> TALLOC_FREE(p);
> - return true;
> + return;
> }
>
> - p->rec_index = BVAL(rec->buf.data, 0);
> + p->rec_index = BVAL(data->data, 0);
>
> p->db = db_open_rbt(p);
> if (p->db == NULL) {
> DEBUG(10, ("%s: db_open_rbt failed\n", __func__));
> TALLOC_FREE(p);
> - return true;
> + return;
> }
>
> - status = dbwrap_unmarshall(p->db, rec->buf.data + 8,
> - rec->buf.length - 8);
> + status = dbwrap_unmarshall(p->db, data->data + 8,
> + data->length - 8);
> if (!NT_STATUS_IS_OK(status)) {
> DEBUG(10, ("%s: dbwrap_unmarshall returned %s for db %s\n",
> __func__, nt_errstr(status),
> - server_id_str_buf(rec->src, &idbuf)));
> + server_id_str_buf(src, &idbuf)));
> TALLOC_FREE(p);
> - return true;
> + return;
> }
>
> dbwrap_traverse_read(p->db, notifyd_add_proxy_syswatches, state,
> &count);
>
> DEBUG(10, ("%s: Database from %s contained %d records\n", __func__,
> - server_id_str_buf(rec->src, &idbuf), count));
> -
> - return true;
> + server_id_str_buf(src, &idbuf), count));
> }
>
> static void notifyd_broadcast_reclog(struct ctdbd_connection *ctdbd_conn,
> --
> 2.1.4
>
>
> From 420029b9b4c2bff8903e7a0a519bd516ac5e1ff6 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 08:57:18 +0200
> Subject: [PATCH 09/10] notifyd: Remove notifyd_handler_done
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/smbd/notifyd/notifyd.c | 13 -------------
> 1 file changed, 13 deletions(-)
>
> diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
> index bc69485..caf894e 100644
> --- a/source3/smbd/notifyd/notifyd.c
> +++ b/source3/smbd/notifyd/notifyd.c
> @@ -176,8 +176,6 @@ static int sys_notify_watch_dummy(
> return 0;
> }
>
> -static void notifyd_handler_done(struct tevent_req *subreq);
> -
> #ifdef CLUSTER_SUPPORT
> static void notifyd_broadcast_reclog_finished(struct tevent_req *subreq);
> static void notifyd_clean_peers_finished(struct tevent_req *subreq);
> @@ -312,17 +310,6 @@ deregister_rec_change:
> return tevent_req_post(req, ev);
> }
>
> -static void notifyd_handler_done(struct tevent_req *subreq)
> -{
> - struct tevent_req *req = tevent_req_callback_data(
> - subreq, struct tevent_req);
> - int ret;
> -
> - ret = messaging_handler_recv(subreq);
> - TALLOC_FREE(subreq);
> - tevent_req_error(req, ret);
> -}
> -
> #ifdef CLUSTER_SUPPORT
>
> static void notifyd_broadcast_reclog_finished(struct tevent_req *subreq)
> --
> 2.1.4
>
>
> From 534ad83ed7377512fb1346d78d875511f00adb1b Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Sat, 24 Jun 2017 09:01:46 +0200
> Subject: [PATCH 10/10] messaging: Remove messaging_handler_send
>
> This did not really take off, notifyd was the only user
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/include/messages.h | 8 -----
> source3/lib/messages.c | 81 ----------------------------------------------
> 2 files changed, 89 deletions(-)
>
> diff --git a/source3/include/messages.h b/source3/include/messages.h
> index 46dc6c0..970dc38 100644
> --- a/source3/include/messages.h
> +++ b/source3/include/messages.h
> @@ -133,14 +133,6 @@ struct tevent_req *messaging_read_send(TALLOC_CTX *mem_ctx,
> int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
> struct messaging_rec **presult);
>
> -struct tevent_req *messaging_handler_send(
> - TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> - struct messaging_context *msg_ctx, uint32_t msg_type,
> - bool (*handler)(struct messaging_context *msg_ctx,
> - struct messaging_rec **rec, void *private_data),
> - void *private_data);
> -int messaging_handler_recv(struct tevent_req *req);
> -
> int messaging_cleanup(struct messaging_context *msg_ctx, pid_t pid);
>
> bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg);
> diff --git a/source3/lib/messages.c b/source3/lib/messages.c
> index da13a1e..b94a696 100644
> --- a/source3/lib/messages.c
> +++ b/source3/lib/messages.c
> @@ -906,87 +906,6 @@ int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
> return 0;
> }
>
> -struct messaging_handler_state {
> - struct tevent_context *ev;
> - struct messaging_context *msg_ctx;
> - uint32_t msg_type;
> - bool (*handler)(struct messaging_context *msg_ctx,
> - struct messaging_rec **rec, void *private_data);
> - void *private_data;
> -};
> -
> -static void messaging_handler_got_msg(struct tevent_req *subreq);
> -
> -struct tevent_req *messaging_handler_send(
> - TALLOC_CTX *mem_ctx, struct tevent_context *ev,
> - struct messaging_context *msg_ctx, uint32_t msg_type,
> - bool (*handler)(struct messaging_context *msg_ctx,
> - struct messaging_rec **rec, void *private_data),
> - void *private_data)
> -{
> - struct tevent_req *req, *subreq;
> - struct messaging_handler_state *state;
> -
> - req = tevent_req_create(mem_ctx, &state,
> - struct messaging_handler_state);
> - if (req == NULL) {
> - return NULL;
> - }
> - state->ev = ev;
> - state->msg_ctx = msg_ctx;
> - state->msg_type = msg_type;
> - state->handler = handler;
> - state->private_data = private_data;
> -
> - subreq = messaging_read_send(state, state->ev, state->msg_ctx,
> - state->msg_type);
> - if (tevent_req_nomem(subreq, req)) {
> - return tevent_req_post(req, ev);
> - }
> - tevent_req_set_callback(subreq, messaging_handler_got_msg, req);
> - return req;
> -}
> -
> -static void messaging_handler_got_msg(struct tevent_req *subreq)
> -{
> - struct tevent_req *req = tevent_req_callback_data(
> - subreq, struct tevent_req);
> - struct messaging_handler_state *state = tevent_req_data(
> - req, struct messaging_handler_state);
> - struct messaging_rec *rec;
> - int ret;
> - bool ok;
> -
> - ret = messaging_read_recv(subreq, state, &rec);
> - TALLOC_FREE(subreq);
> - if (tevent_req_error(req, ret)) {
> - return;
> - }
> -
> - subreq = messaging_read_send(state, state->ev, state->msg_ctx,
> - state->msg_type);
> - if (tevent_req_nomem(subreq, req)) {
> - return;
> - }
> - tevent_req_set_callback(subreq, messaging_handler_got_msg, req);
> -
> - ok = state->handler(state->msg_ctx, &rec, state->private_data);
> - TALLOC_FREE(rec);
> - if (ok) {
> - /*
> - * Next round
> - */
> - return;
> - }
> - TALLOC_FREE(subreq);
> - tevent_req_done(req);
> -}
> -
> -int messaging_handler_recv(struct tevent_req *req)
> -{
> - return tevent_req_simple_recv_unix(req);
> -}
> -
> static bool messaging_append_new_waiters(struct messaging_context *msg_ctx)
> {
> if (msg_ctx->num_new_waiters == 0) {
> --
> 2.1.4
>
More information about the samba-technical
mailing list