From d669bd82436006e06a77e0eb9d8e47253324398a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 19 May 2015 22:15:57 +0200 Subject: [PATCH] ctdbd_conn: Move ctdbd_register_reconfigure to a callback Move functionality out of ctdbd_conn to its right place into smbd Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- source3/include/ctdbd_conn.h | 2 -- source3/lib/ctdb_dummy.c | 5 ----- source3/lib/ctdbd_conn.c | 43 ------------------------------------ source3/smbd/server.c | 25 ++++++++++++++++++++- 4 files changed, 24 insertions(+), 51 deletions(-) diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h index 397c09331f5..13889fc8be8 100644 --- a/source3/include/ctdbd_conn.h +++ b/source3/include/ctdbd_conn.h @@ -82,8 +82,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, void *private_data), void *private_data); -NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn); - NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode, uint64_t srvid, uint32_t flags, TDB_DATA data, TALLOC_CTX *mem_ctx, TDB_DATA *outdata, diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c index ca1309b0311..50de9ad72a0 100644 --- a/source3/lib/ctdb_dummy.c +++ b/source3/lib/ctdb_dummy.c @@ -52,11 +52,6 @@ NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn) -{ - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, const struct sockaddr_storage *_server, const struct sockaddr_storage *_client, diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 4e030184b22..d380b458bf8 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -394,20 +394,6 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, goto next_pkt; } - if ((msg->srvid == CTDB_SRVID_RECONFIGURE) - || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)) { - - DEBUG(1, ("ctdb_read_req: Got %s message\n", - (msg->srvid == CTDB_SRVID_RECONFIGURE) - ? "cluster reconfigure" : "SAMBA_NOTIFY")); - - messaging_send(conn->msg_ctx, - messaging_server_id(conn->msg_ctx), - MSG_SMB_BRL_VALIDATE, &data_blob_null); - TALLOC_FREE(hdr); - goto next_pkt; - } - ctdbd_msg_call_back(conn, msg); TALLOC_FREE(hdr); goto next_pkt; @@ -508,12 +494,6 @@ NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx, goto fail; } - status = register_with_ctdbd(conn, CTDB_SRVID_SAMBA_NOTIFY, - NULL, NULL); - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - *pconn = conn; return NT_STATUS_OK; @@ -571,21 +551,6 @@ static NTSTATUS ctdb_handle_message(struct messaging_context *msg_ctx, SMB_ASSERT(conn->msg_ctx != NULL); - if ((msg->srvid == CTDB_SRVID_RECONFIGURE) - || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)){ - DEBUG(0,("Got cluster reconfigure message\n")); - /* - * when the cluster is reconfigured or someone of the - * family has passed away (SAMBA_NOTIFY), we need to - * clean the brl database - */ - messaging_send(conn->msg_ctx, - messaging_server_id(conn->msg_ctx), - MSG_SMB_BRL_VALIDATE, &data_blob_null); - - return NT_STATUS_OK; - } - ctdbd_msg_call_back(conn, msg); return NT_STATUS_OK; @@ -1583,14 +1548,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn, CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL, NULL); } -/* - * We want to handle reconfigure events - */ -NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn) -{ - return register_with_ctdbd(conn, CTDB_SRVID_RECONFIGURE, NULL, NULL); -} - /* call a control on the local node */ diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 18334626d2c..9746d849be0 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -48,6 +48,7 @@ #include "lib/smbd_shim.h" #include "scavenger.h" #include "locking/leases_db.h" +#include "../../ctdb/include/ctdb_protocol.h" struct smbd_open_socket; struct smbd_child_pid; @@ -260,6 +261,23 @@ static void smbd_parent_id_cache_delete(struct messaging_context *ctx, messaging_send_to_children(ctx, msg_type, msg_data); } +static void smbd_parent_ctdb_reconfigured(struct ctdb_req_message *msg, + void *private_data) +{ + struct messaging_context *msg_ctx = talloc_get_type_abort( + private_data, struct messaging_context); + + DEBUG(10, ("Got %s message\n", (msg->srvid == CTDB_SRVID_RECONFIGURE) + ? "cluster reconfigure" : "SAMBA_NOTIFY")); + + /* + * Someone from the family died, validate our locks + */ + + messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx), + MSG_SMB_BRL_VALIDATE, NULL, 0); +} + struct smbd_parent_notify_state { struct tevent_context *ev; struct messaging_context *msg; @@ -898,7 +916,12 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent, ID_CACHE_KILL, smbd_parent_id_cache_kill); if (lp_clustering()) { - ctdbd_register_reconfigure(messaging_ctdbd_connection()); + struct ctdbd_connection *conn = messaging_ctdbd_connection(); + + register_with_ctdbd(conn, CTDB_SRVID_RECONFIGURE, + smbd_parent_ctdb_reconfigured, msg_ctx); + register_with_ctdbd(conn, CTDB_SRVID_SAMBA_NOTIFY, + smbd_parent_ctdb_reconfigured, msg_ctx); } #ifdef DEVELOPER