|
 |
fada68 |
From 9b4ee98cbfdadcd9f9bc479de0c14a233b46bda7 Mon Sep 17 00:00:00 2001
|
|
 |
fada68 |
From: HideoYamauchi <renayama19661014@ybb.ne.jp>
|
|
 |
fada68 |
Date: Tue, 26 Jul 2016 13:31:42 +0900
|
|
 |
fada68 |
Subject: [PATCH] High: lib: Correction of the deletion of the notice
|
|
 |
fada68 |
registration.
|
|
 |
fada68 |
|
|
 |
fada68 |
---
|
|
 |
fada68 |
lib/cib/cib_client.c | 30 ++++++++++++++++++++++++++++--
|
|
 |
fada68 |
1 file changed, 28 insertions(+), 2 deletions(-)
|
|
 |
fada68 |
|
|
 |
fada68 |
diff --git a/lib/cib/cib_client.c b/lib/cib/cib_client.c
|
|
 |
fada68 |
index f7a19b8..b0d156c 100644
|
|
 |
fada68 |
--- a/lib/cib/cib_client.c
|
|
 |
fada68 |
+++ b/lib/cib/cib_client.c
|
|
 |
fada68 |
@@ -477,6 +477,23 @@ cib_client_add_notify_callback(cib_t * cib, const char *event,
|
|
 |
fada68 |
return pcmk_ok;
|
|
 |
fada68 |
}
|
|
 |
fada68 |
|
|
 |
fada68 |
+static int
|
|
 |
fada68 |
+get_notify_list_event_count(cib_t * cib, const char *event)
|
|
 |
fada68 |
+{
|
|
 |
fada68 |
+ GList *l = NULL;
|
|
 |
fada68 |
+ int count = 0;
|
|
 |
fada68 |
+
|
|
 |
fada68 |
+ for (l = g_list_first(cib->notify_list); l; l = g_list_next(l)) {
|
|
 |
fada68 |
+ cib_notify_client_t *client = (cib_notify_client_t *)l->data;
|
|
 |
fada68 |
+
|
|
 |
fada68 |
+ if (strcmp(client->event, event) == 0) {
|
|
 |
fada68 |
+ count++;
|
|
 |
fada68 |
+ }
|
|
 |
fada68 |
+ }
|
|
 |
fada68 |
+ crm_trace("event(%s) count : %d", event, count);
|
|
 |
fada68 |
+ return count;
|
|
 |
fada68 |
+}
|
|
 |
fada68 |
+
|
|
 |
fada68 |
int
|
|
 |
fada68 |
cib_client_del_notify_callback(cib_t * cib, const char *event,
|
|
 |
fada68 |
void (*callback) (const char *event, xmlNode * msg))
|
|
 |
fada68 |
@@ -488,6 +505,11 @@ cib_client_del_notify_callback(cib_t * cib, const char *event,
|
|
 |
fada68 |
return -EPROTONOSUPPORT;
|
|
 |
fada68 |
}
|
|
 |
fada68 |
|
|
 |
fada68 |
+ if (get_notify_list_event_count(cib, event) == 0) {
|
|
 |
fada68 |
+ crm_debug("The callback of the event does not exist(%s)", event);
|
|
 |
fada68 |
+ return pcmk_ok;
|
|
 |
fada68 |
+ }
|
|
 |
fada68 |
+
|
|
 |
fada68 |
crm_debug("Removing callback for %s events", event);
|
|
 |
fada68 |
|
|
 |
fada68 |
new_client = calloc(1, sizeof(cib_notify_client_t));
|
|
 |
fada68 |
@@ -496,8 +518,6 @@ cib_client_del_notify_callback(cib_t * cib, const char *event,
|
|
 |
fada68 |
|
|
 |
fada68 |
list_item = g_list_find_custom(cib->notify_list, new_client, ciblib_GCompareFunc);
|
|
 |
fada68 |
|
|
 |
fada68 |
- cib->cmds->register_notification(cib, event, 0);
|
|
 |
fada68 |
-
|
|
 |
fada68 |
if (list_item != NULL) {
|
|
 |
fada68 |
cib_notify_client_t *list_client = list_item->data;
|
|
 |
fada68 |
|
|
 |
fada68 |
@@ -509,6 +529,12 @@ cib_client_del_notify_callback(cib_t * cib, const char *event,
|
|
 |
fada68 |
} else {
|
|
 |
fada68 |
crm_trace("Callback not present");
|
|
 |
fada68 |
}
|
|
 |
fada68 |
+
|
|
 |
fada68 |
+ if (get_notify_list_event_count(cib, event) == 0) {
|
|
 |
fada68 |
+ /* When there is not the registration of the event, the processing turns off a notice. */
|
|
 |
fada68 |
+ cib->cmds->register_notification(cib, event, 0);
|
|
 |
fada68 |
+ }
|
|
 |
fada68 |
+
|
|
 |
fada68 |
free(new_client);
|
|
 |
fada68 |
return pcmk_ok;
|
|
 |
fada68 |
}
|
|
 |
fada68 |
--
|
|
 |
fada68 |
1.8.3.1
|
|
 |
fada68 |
|