s4-witness: registering for ctdb events
authorGünther Deschner <gd@samba.org>
Tue, 8 Sep 2015 15:50:31 +0000 (17:50 +0200)
committerGünther Deschner <gd@samba.org>
Sun, 3 Feb 2019 09:26:19 +0000 (10:26 +0100)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
source4/rpc_server/witness/dcesrv_witness.c

index dc934f4828289053cb780b0bb760e867d7dd20b4..c25947787df37f0a441da0198ae81dad24d4c1ca 100644 (file)
 #include "rpc_server/common/common.h"
 #include "lib/witness/witness.h"
 #include "param/param.h"
+#include "system/network.h"
+#include <ctdb_protocol.h>
+#include <ctdb_client.h>
+#include "messages.h"
+#include "ctdbd_conn.h"
+#include "lib/messages_ctdb.h"
+#include "libcli/util/error.h"
 
 /* FIXME */
 #define ADD_TO_ARRAY(mem_ctx, type, elem, array, num) \
@@ -296,6 +303,45 @@ static NTSTATUS dcesrv_interface_witness_bind(struct dcesrv_call_state *dce_call
                return NT_STATUS_FOOBAR;
        }
 
+       if (lpcfg_clustering(dce_call->conn->dce_ctx->lp_ctx)) {
+
+               struct ctdbd_connection *conn;
+               int ret;
+
+               conn = messaging_ctdb_connection();
+               if (conn == NULL) {
+                       return NT_STATUS_UNSUCCESSFUL;
+               }
+
+               ret = register_with_ctdbd(conn,
+                                         CTDB_SRVID_RECONFIGURE,
+                                         witnessd_ctdb_reconfigured,
+                                         dce_call->msg_ctx);
+               if (ret != 0) {
+                       DEBUG(1,("%s: failed to register for event\n",  __location__));
+                       return map_nt_error_from_unix_common(ret);
+               }
+
+               ret = register_with_ctdbd(conn,
+                                         CTDB_SRVID_RELEASE_IP,
+                                         witnessd_ctdb_reconfigured,
+                                         dce_call->msg_ctx);
+               if (ret != 0) {
+                       DEBUG(1,("%s: failed to register for event\n",  __location__));
+                       return map_nt_error_from_unix_common(ret);
+               }
+
+               ret = register_with_ctdbd(conn,
+                                         CTDB_SRVID_TAKE_IP,
+                                         witnessd_ctdb_reconfigured,
+                                         dce_call->msg_ctx);
+               if (ret != 0) {
+                       DEBUG(1,("%s: failed to register for event\n",  __location__));
+                       return map_nt_error_from_unix_common(ret);
+               }
+               DEBUG(1,("%s: registered for three events\n", __location__));
+       }
+
        return NT_STATUS_OK;
 }