From 77a559432ffde2d435e29bed126d20a09d33f48e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 16 Nov 2023 13:04:12 +0100 Subject: [PATCH] ctdbd_conn: let register_with_ctdbd() call CTDB_CONTROL_REGISTER_SRVID just once We do the dispatching to multiple handlers in ctdbd_msg_call_back() and we don't need more than one message from ctdb. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15523 Signed-off-by: Stefan Metzmacher Reviewed-by: Martin Schwenke --- source3/lib/ctdbd_conn.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 4382bae54fc..a11c31d7f63 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -131,19 +131,32 @@ int register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid, void *private_data), void *private_data) { - - int ret; - int32_t cstatus; - size_t num_callbacks; + size_t num_callbacks = talloc_array_length(conn->callbacks); struct ctdbd_srvid_cb *tmp; + bool need_register = true; + size_t i; - ret = ctdbd_control_local(conn, CTDB_CONTROL_REGISTER_SRVID, srvid, 0, - tdb_null, NULL, NULL, &cstatus); - if (ret != 0) { - return ret; + for (i = 0; i < num_callbacks; i++) { + struct ctdbd_srvid_cb *c = &conn->callbacks[i]; + + if (c->srvid == srvid) { + need_register = false; + break; + } + } + + if (need_register) { + int ret; + int32_t cstatus; + + ret = ctdbd_control_local(conn, CTDB_CONTROL_REGISTER_SRVID, + srvid, 0, tdb_null, NULL, NULL, + &cstatus); + if (ret != 0) { + return ret; + } } - num_callbacks = talloc_array_length(conn->callbacks); tmp = talloc_realloc(conn, conn->callbacks, struct ctdbd_srvid_cb, num_callbacks + 1); -- 2.47.2