]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
notifyd: Only ask for messaging_ctdb_conn when clustering
authorVolker Lendecke <vl@samba.org>
Fri, 16 Jun 2017 13:20:22 +0000 (15:20 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 25 Oct 2017 06:43:00 +0000 (08:43 +0200)
Without clustering, messaging_ctdb_conn will fail anyway.

Review with "git show -b".

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12903

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 939576d968d1e0159456baf6dd1e3c454b98995a)

source3/smbd/notifyd/notifyd.c
source3/smbd/server.c

index 087952ad9d770d792bb8fca3e868aa68bce99a2e..0de56dab2ad22a7c3dbfc4763c26b6ef3c6b3152 100644 (file)
@@ -241,13 +241,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);
@@ -269,32 +271,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
 
index f97b5e8f2abe1e11cb3c57c8ae5701f3b1cb83b7..3362c5ae72064af636995c7ae54827253bd605be 100644 (file)
@@ -331,6 +331,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()) {
 
@@ -355,8 +356,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);