There is on important notification missing from confdb and that is for a whole objdb reload. This patch adds that feature.

Actually here are two patches, the confdb reload patch and another that fixes a couple of related bugs that 1) cause reload notifications not to work at all, and 2) cause the number of reload callbacks to increased exponentially each time a reload happens.

Chrissie
Index: services/confdb.c
===================================================================
--- services/confdb.c   (revision 2682)
+++ services/confdb.c   (working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008-2009 Red Hat, Inc.
+ * Copyright (c) 2008-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -137,6 +137,11 @@
        const uint8_t *name_pt, size_t name_len,
        void *priv_data_pt);
 
+static void confdb_notify_lib_of_reload(
+       objdb_reload_notify_type_t notify_type,
+       int flush,
+       void *priv_data_pt);
+
 /*
  * Library Handler Definition
  */
@@ -814,7 +819,21 @@
        api->ipc_dispatch_send(priv_data_pt, &res, sizeof(res));
 }
 
+static void confdb_notify_lib_of_reload(objdb_reload_notify_type_t notify_type,
+                                       int flush,
+                                       void *priv_data_pt)
+{
+       struct res_lib_confdb_reload_callback res;
 
+       res.header.size = sizeof(res);
+       res.header.id = MESSAGE_RES_CONFDB_RELOAD_CALLBACK;
+       res.header.error = CS_OK;
+       res.type = notify_type;
+
+       api->ipc_dispatch_send(priv_data_pt, &res, sizeof(res));
+}
+
+
 static void message_handler_req_lib_confdb_track_start (void *conn,
                                                        const void *message)
 {
@@ -826,7 +845,7 @@
                confdb_notify_lib_of_key_change,
                confdb_notify_lib_of_new_object,
                confdb_notify_lib_of_destroyed_object,
-               NULL,
+               confdb_notify_lib_of_reload,
                conn);
        res.size = sizeof(res);
        res.id = MESSAGE_RES_CONFDB_TRACK_START;
@@ -842,7 +861,7 @@
        api->object_track_stop(confdb_notify_lib_of_key_change,
                confdb_notify_lib_of_new_object,
                confdb_notify_lib_of_destroyed_object,
-               NULL,
+               confdb_notify_lib_of_reload,
                conn);
 
        res.size = sizeof(res);
Index: include/corosync/confdb.h
===================================================================
--- include/corosync/confdb.h   (revision 2682)
+++ include/corosync/confdb.h   (working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Red Hat, Inc.
+ * Copyright (c) 2008-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -71,9 +71,15 @@
 typedef enum {
        OBJECT_KEY_CREATED,
        OBJECT_KEY_REPLACED,
-       OBJECT_KEY_DELETED
+       OBJECT_KEY_DELETED,
 } confdb_change_type_t;
 
+typedef enum {
+       CONFDB_RELOAD_NOTIFY_START,
+        CONFDB_RELOAD_NOTIFY_END,
+       CONFDB_RELOAD_NOTIFY_FAILED
+} confdb_reload_type_t;
+
 typedef void (*confdb_key_change_notify_fn_t) (
        confdb_handle_t handle,
        confdb_change_type_t change_type,
@@ -99,10 +105,15 @@
        const void *name_pt,
        size_t name_len);
 
+typedef void (*confdb_reload_notify_fn_t) (
+       confdb_handle_t handle,
+       confdb_reload_type_t type);
+
 typedef struct {
        confdb_object_create_notify_fn_t confdb_object_create_change_notify_fn;
        confdb_object_delete_notify_fn_t confdb_object_delete_change_notify_fn;
        confdb_key_change_notify_fn_t confdb_key_change_notify_fn;
+       confdb_reload_notify_fn_t confdb_reload_notify_fn;
 } confdb_callbacks_t;
 
 /** @} */
Index: include/corosync/ipc_confdb.h
===================================================================
--- include/corosync/ipc_confdb.h       (revision 2682)
+++ include/corosync/ipc_confdb.h       (working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2008-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -84,6 +84,7 @@
        MESSAGE_RES_CONFDB_KEY_DECREMENT = 19,
        MESSAGE_RES_CONFDB_KEY_GET_TYPED = 20,
        MESSAGE_RES_CONFDB_KEY_ITER_TYPED = 21,
+       MESSAGE_RES_CONFDB_RELOAD_CALLBACK = 22,
 };
 
 
@@ -252,6 +253,11 @@
        mar_name_t name __attribute__((aligned(8)));
 };
 
+struct res_lib_confdb_reload_callback {
+       coroipc_response_header_t header __attribute__((aligned(8)));
+       mar_uint32_t type __attribute__((aligned(8)));
+};
+
 struct req_lib_confdb_object_track_start {
        coroipc_request_header_t header __attribute__((aligned(8)));
        mar_uint64_t object_handle __attribute__((aligned(8)));
Index: lib/confdb.c
===================================================================
--- lib/confdb.c        (revision 2682)
+++ lib/confdb.c        (working copy)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008-2009 Red Hat, Inc.
+ * Copyright (c) 2008-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -284,6 +284,7 @@
        struct res_lib_confdb_key_change_callback *res_key_changed_pt;
        struct res_lib_confdb_object_create_callback *res_object_created_pt;
        struct res_lib_confdb_object_destroy_callback *res_object_destroyed_pt;
+       struct res_lib_confdb_reload_callback *res_reload_pt;
        coroipc_response_header_t *dispatch_data;
 
        error = hdb_error_to_cs(hdb_handle_get (&confdb_handle_t_db, handle, 
(void *)&confdb_inst));
@@ -298,7 +299,7 @@
 
        /*
         * Timeout instantly for CS_DISPATCH_ONE or CS_DISPATCH_ALL and
-        * wait indefinately for CS_DISPATCH_BLOCKING
+        * wait indefinitely for CS_DISPATCH_BLOCKING
         */
        if (dispatch_types == CONFDB_DISPATCH_ALL) {
                timeout = 0;
@@ -384,6 +385,17 @@
                                        res_object_destroyed_pt->name.length);
                                break;
 
+                       case MESSAGE_RES_CONFDB_RELOAD_CALLBACK:
+                               if (callbacks.confdb_reload_notify_fn == NULL) {
+                                       continue;
+                               }
+
+                               res_reload_pt = (struct 
res_lib_confdb_reload_callback *)dispatch_data;
+
+                               callbacks.confdb_reload_notify_fn(handle,
+                                       res_reload_pt->type);
+                               break;
+
                        default:
                                coroipcc_dispatch_put (confdb_inst->handle);
                                error = CS_ERR_LIBRARY;
Index: exec/objdb.c
===================================================================
--- exec/objdb.c        (revision 2682)
+++ exec/objdb.c        (working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2006 MontaVista Software, Inc.
- * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Copyright (c) 2007-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -352,6 +352,7 @@
                        if (tmptracker_pt) {
                                list_add(&tmptracker_pt->object_list, &tmplist);
                                tmptracker_pt->object_reload_notify_fn = 
tracker_pt->object_reload_notify_fn;
+                               tmptracker_pt->data_pt = tracker_pt->data_pt;
                        }
                }
        }
Index: exec/totemconfig.c
===================================================================
--- exec/totemconfig.c  (revision 2682)
+++ exec/totemconfig.c  (working copy)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2002-2005 MontaVista Software, Inc.
- * Copyright (c) 2006-2009 Red Hat, Inc.
+ * Copyright (c) 2006-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -818,6 +818,9 @@
        struct totem_config *totem_config = priv_data_pt;
        hdb_handle_t totem_object_handle;
 
+       if (totem_config == NULL)
+               return;
+
        /*
         * A new totem {} key might exist, cancel the
         * existing notification at the start of reload,
@@ -831,7 +834,7 @@
                        NULL,
                        NULL,
                        NULL,
-                       NULL);
+                       totem_config);
        }
 
        if (type == OBJDB_RELOAD_NOTIFY_END ||
@@ -840,8 +843,14 @@
 
                if (!totem_handle_find(global_objdb,
                                      &totem_object_handle)) {
-                       add_totem_config_notification(global_objdb, 
totem_config, totem_object_handle);
 
+                       global_objdb->object_track_start(totem_object_handle,
+                                                 1,
+                                                 totem_key_change_notify,
+                                                 NULL, // object_create_notify,
+                                                 NULL, // 
object_destroy_notify,
+                                                 NULL, // object_reload_notify
+                                                 totem_config); // priv_data
                        /*
                         * Reload the configuration
                         */
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to