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)
committerJeremy Allison <jra@samba.org>
Thu, 6 Jul 2017 22:52:24 +0000 (00:52 +0200)
Without clustering, messaging_ctdb_conn will fail anyway.

Review with "git show -b".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/notifyd/notifyd.c
source3/smbd/server.c

index f02ccfa11d37d31c63ee739e8581382030a65d8a..377d9535aa813a2b426cfee7ad058851a0612e13 100644 (file)
@@ -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
 
index fa13dbc9b18c7038e1fd08ae6c59cd415b3f00f4..e18a4e55260cc730f328a0b21f2d39aaab2f4132 100644 (file)
@@ -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);