summaryrefslogtreecommitdiff
path: root/ctdb/common
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-08-30 13:27:12 +1000
committerMartin Schwenke <martins@samba.org>2017-09-21 08:53:26 +0200
commite675f346805de1754a6b18cf0dfbc71df9c7a05d (patch)
tree3865ba937a2188411b56f0c667f84d4a56b83b5f /ctdb/common
parent30ffc120e299df1b346f664910cf9d73d3fe7dd9 (diff)
downloadsamba-e675f346805de1754a6b18cf0dfbc71df9c7a05d.tar.gz
ctdb-common: Extend srvid_exists() check to support optional private_data
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13042 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/common')
-rw-r--r--ctdb/common/srvid.c13
-rw-r--r--ctdb/common/srvid.h8
2 files changed, 19 insertions, 2 deletions
diff --git a/ctdb/common/srvid.c b/ctdb/common/srvid.c
index f9cd49b4ea3..33049941e69 100644
--- a/ctdb/common/srvid.c
+++ b/ctdb/common/srvid.c
@@ -221,9 +221,10 @@ int srvid_deregister(struct srvid_context *srv, uint64_t srvid,
/*
* Check if a message handler exists
*/
-int srvid_exists(struct srvid_context *srv, uint64_t srvid)
+int srvid_exists(struct srvid_context *srv, uint64_t srvid, void *private_data)
{
struct srvid_handler_list *list;
+ struct srvid_handler *h;
int ret;
ret = srvid_fetch(srv, srvid, &list);
@@ -234,6 +235,16 @@ int srvid_exists(struct srvid_context *srv, uint64_t srvid)
return ENOENT;
}
+ if (private_data != NULL) {
+ for (h = list->h; h != NULL; h = h->next) {
+ if (h->private_data == private_data) {
+ return 0;
+ }
+ }
+
+ return ENOENT;
+ }
+
return 0;
}
diff --git a/ctdb/common/srvid.h b/ctdb/common/srvid.h
index f048b5c6cbf..702724ff93a 100644
--- a/ctdb/common/srvid.h
+++ b/ctdb/common/srvid.h
@@ -91,11 +91,17 @@ int srvid_deregister(struct srvid_context *srv, uint64_t srvid,
/**
* @brief Check if any message handler is registered for srvid
*
+ * If private_data is NULL, then check if there is any registration
+ * for * specified srvid. If private_data is not NULL, then check for
+ * registration that matches the specified private data.
+ *
* @param[in] srv The srvid message handler database context
* @param[in] srvid The srvid
+ * @param[in] private_data Private data
* @return 0 on success, errno on failure
*/
-int srvid_exists(struct srvid_context *srv, uint64_t srvid);
+int srvid_exists(struct srvid_context *srv, uint64_t srvid,
+ void *private_data);
/**
* @brief Call message handlers for given srvid