Преглед изворни кода

Merge trunk revision 2683:
r2683 | chrissie | 2010-03-16 02:51:30 -0700 (Tue, 16 Mar 2010) | 5 lines

Add a reload callback to libconfdb.

This also increments the libconfdb version to 4.1.0



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2802 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake пре 16 година
родитељ
комит
32b2be69a1
4 измењених фајлова са 56 додато и 8 уклоњено
  1. 13 2
      include/corosync/confdb.h
  2. 7 1
      include/corosync/ipc_confdb.h
  3. 14 2
      lib/confdb.c
  4. 22 3
      services/confdb.c

+ 13 - 2
include/corosync/confdb.h

@@ -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 {
 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 @@ typedef void (*confdb_object_delete_notify_fn_t) (
 	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;
 
 /** @} */

+ 7 - 1
include/corosync/ipc_confdb.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2008-2010 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -84,6 +84,7 @@ enum res_confdb_types {
 	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 @@ struct res_lib_confdb_object_destroy_callback {
 	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)));

+ 14 - 2
lib/confdb.c

@@ -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 @@ cs_error_t confdb_dispatch (
 	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 @@ cs_error_t confdb_dispatch (
 
 	/*
 	 * 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 @@ cs_error_t confdb_dispatch (
 					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;

+ 22 - 3
services/confdb.c

@@ -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 @@ static void confdb_notify_lib_of_destroyed_object(
 	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,6 +819,20 @@ static void confdb_notify_lib_of_destroyed_object(
 	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 @@ static void message_handler_req_lib_confdb_track_start (void *conn,
 		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 @@ static void message_handler_req_lib_confdb_track_stop (void *conn,
 	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);