On Mon, 30 Jun 2008, Fabio M. Di Nitto wrote:
Hi Steven and Chrissie,
as posted before, this is the final and working version of the objdb_reload
implementation.
Please apply
Patch updated after Chrissie's comments on making reload tests optionals.
Fabio
--
I'm going to make him an offer he can't refuse.
Index: test/testconfdb.c
===================================================================
--- test/testconfdb.c (revision 1568)
+++ test/testconfdb.c (working copy)
@@ -176,6 +176,15 @@
if (argv[1] && strcmp(argv[1], "write")==0)
do_write_tests(handle);
+ if (argv[1] && strcmp(argv[1], "reload")==0) {
+ /* Test reload interface */
+ result = confdb_reload(handle, 0, key_value);
+ printf ("Try to reload the config (noflush): %d (should be
1)\n", result);
+
+ result = confdb_reload(handle, 1, key_value);
+ printf ("Try to reload the config (flush): %d (should be 1)\n",
result);
+ }
+
/* Test iterators */
print_config_tree(handle, OBJECT_PARENT_HANDLE, 0);
Index: include/confdb.h
===================================================================
--- include/confdb.h (revision 1568)
+++ include/confdb.h (working copy)
@@ -105,6 +105,14 @@
char *error_text);
/*
+ * Reload the configuration
+ */
+confdb_error_t confdb_reload (
+ confdb_handle_t handle,
+ int flush,
+ char *error_text);
+
+/*
* Get a file descriptor on which to poll. confdb_handle_t is NOT a
* file descriptor and may not be used directly.
*/
Index: include/ipc_confdb.h
===================================================================
--- include/ipc_confdb.h (revision 1568)
+++ include/ipc_confdb.h (working copy)
@@ -51,7 +51,8 @@
MESSAGE_REQ_CONFDB_KEY_ITER = 9,
MESSAGE_REQ_CONFDB_TRACK_START = 10,
MESSAGE_REQ_CONFDB_TRACK_STOP = 11,
- MESSAGE_REQ_CONFDB_WRITE = 12
+ MESSAGE_REQ_CONFDB_WRITE = 12,
+ MESSAGE_REQ_CONFDB_RELOAD = 13
};
enum res_confdb_types {
@@ -68,7 +69,8 @@
MESSAGE_RES_CONFDB_TRACK_START = 10,
MESSAGE_RES_CONFDB_TRACK_STOP = 11,
MESSAGE_RES_CONFDB_CHANGE_CALLBACK = 12,
- MESSAGE_RES_CONFDB_WRITE = 13
+ MESSAGE_RES_CONFDB_WRITE = 13,
+ MESSAGE_RES_CONFDB_RELOAD = 14
};
@@ -174,6 +176,12 @@
mar_name_t error __attribute__((aligned(8)));
};
+struct res_lib_confdb_reload {
+ mar_res_header_t header __attribute__((aligned(8)));
+ mar_int32_t flush __attribute__((aligned(8)));
+ mar_name_t error __attribute__((aligned(8)));
+};
+
struct res_lib_confdb_change_callback {
mar_res_header_t header __attribute__((aligned(8)));
mar_uint32_t parent_object_handle __attribute__((aligned(8)));
Index: exec/config.h
===================================================================
--- exec/config.h (revision 1568)
+++ exec/config.h (working copy)
@@ -38,6 +38,7 @@
struct config_iface_ver0 {
int (*config_readconfig) (struct objdb_iface_ver0 *objdb, char
**error_string);
int (*config_writeconfig) (struct objdb_iface_ver0 *objdb, char
**error_string);
+ int (*config_reloadconfig) (struct objdb_iface_ver0 *objdb, int flush,
char **error_string);
};
Index: exec/objdb.c
===================================================================
--- exec/objdb.c (revision 1568)
+++ exec/objdb.c (working copy)
@@ -1107,6 +1107,24 @@
return 0;
}
+static int object_reload_config(int flush, char **error_string)
+{
+ struct config_iface_ver0 **modules;
+ int num_modules;
+ int i;
+ int res;
+
+ main_get_config_modules(&modules, &num_modules);
+ for (i=0; i<num_modules; i++) {
+ if (modules[i]->config_reloadconfig) {
+ res = modules[i]->config_reloadconfig(&objdb_iface,
flush, error_string);
+ if (res)
+ return res;
+ }
+ }
+ return 0;
+}
+
struct objdb_iface_ver0 objdb_iface = {
.objdb_init = objdb_init,
.object_create = object_create,
@@ -1131,6 +1149,7 @@
.object_parent_get = object_parent_get,
.object_dump = object_dump,
.object_write_config = object_write_config,
+ .object_reload_config = object_reload_config,
};
struct lcr_iface objdb_iface_ver0[1] = {
Index: exec/objdb.h
===================================================================
--- exec/objdb.h (revision 1568)
+++ exec/objdb.h (working copy)
@@ -170,6 +170,11 @@
int *value_len);
int (*object_write_config) (char **error_string);
+
+ int (*object_reload_config) (
+ int flush,
+ char **error_string);
+
};
#endif /* OBJDB_H_DEFINED */
Index: exec/confdb.c
===================================================================
--- exec/confdb.c (revision 1568)
+++ exec/confdb.c (working copy)
@@ -74,6 +74,7 @@
static void message_handler_req_lib_confdb_object_parent_get (void *conn, void
*message);
static void message_handler_req_lib_confdb_write (void *conn, void *message);
+static void message_handler_req_lib_confdb_reload (void *conn, void *message);
static void message_handler_req_lib_confdb_track_start (void *conn, void
*message);
static void message_handler_req_lib_confdb_track_stop (void *conn, void
*message);
@@ -162,6 +163,12 @@
.response_id =
MESSAGE_RES_CONFDB_WRITE,
.flow_control =
OPENAIS_FLOW_CONTROL_NOT_REQUIRED
},
+ { /* 13 */
+ .lib_handler_fn =
message_handler_req_lib_confdb_reload,
+ .response_size = sizeof (struct
res_lib_confdb_reload),
+ .response_id =
MESSAGE_RES_CONFDB_RELOAD,
+ .flow_control =
OPENAIS_FLOW_CONTROL_NOT_REQUIRED
+ },
};
@@ -469,6 +476,29 @@
openais_conn_send_response(conn, &res_lib_confdb_write,
sizeof(res_lib_confdb_write));
}
+static void message_handler_req_lib_confdb_reload (void *conn, void *message)
+{
+ struct res_lib_confdb_reload *req_lib_confdb_reload = (struct
res_lib_confdb_reload *)message;
+ struct res_lib_confdb_reload res_lib_confdb_reload;
+
+ int ret = SA_AIS_OK;
+ char *error_string = NULL;
+
+ if (global_objdb->object_reload_config(req_lib_confdb_reload->flush,
&error_string))
+ ret = SA_AIS_ERR_ACCESS;
+
+ res_lib_confdb_reload.header.size = sizeof(res_lib_confdb_reload);
+ res_lib_confdb_reload.header.id = MESSAGE_RES_CONFDB_RELOAD;
+ res_lib_confdb_reload.header.error = ret;
+ if(error_string) {
+ strcpy((char *)res_lib_confdb_reload.error.value, error_string);
+ res_lib_confdb_reload.error.length = strlen(error_string) + 1;
+ } else
+ res_lib_confdb_reload.error.length = 0;
+
+ openais_conn_send_response(conn, &res_lib_confdb_reload,
sizeof(res_lib_confdb_reload));
+}
+
/* TODO: when we have notification in the objdb. */
static void message_handler_req_lib_confdb_track_start (void *conn, void
*message)
{
Index: lib/sa-confdb.h
===================================================================
--- lib/sa-confdb.h (revision 1568)
+++ lib/sa-confdb.h (working copy)
@@ -43,3 +43,4 @@
extern int confdb_sa_object_iter(unsigned int parent_object_handle, unsigned
int start_pos, unsigned int *object_handle, void *object_name, int
*object_name_len);
extern int confdb_sa_key_iter(unsigned int parent_object_handle, unsigned int
start_pos, void *key_name, int *key_name_len, void *value, int *value_len);
extern int confdb_sa_write(char *error_text);
+extern int confdb_sa_reload(int flush, char *error_text);
Index: lib/confdb.c
===================================================================
--- lib/confdb.c (revision 1568)
+++ lib/confdb.c (working copy)
@@ -1138,4 +1138,54 @@
return (error);
}
+confdb_error_t confdb_reload (
+ confdb_handle_t handle,
+ int flush,
+ char *error_text)
+{
+ confdb_error_t error;
+ struct confdb_inst *confdb_inst;
+ struct iovec iov[2];
+ struct res_lib_confdb_reload res_lib_confdb_reload;
+ error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void
*)&confdb_inst);
+ if (error != SA_AIS_OK) {
+ return (error);
+ }
+
+ if (confdb_inst->standalone) {
+ error = SA_AIS_OK;
+
+ if (confdb_sa_reload(flush, error_text))
+ error = SA_AIS_ERR_ACCESS;
+ goto error_exit;
+ }
+
+ res_lib_confdb_reload.header.size = sizeof (res_lib_confdb_reload);
+ res_lib_confdb_reload.header.id = MESSAGE_REQ_CONFDB_RELOAD;
+ res_lib_confdb_reload.flush = flush;
+
+ iov[0].iov_base = (char *)&res_lib_confdb_reload;
+ iov[0].iov_len = sizeof (res_lib_confdb_reload);
+
+ pthread_mutex_lock (&confdb_inst->response_mutex);
+
+ error = saSendMsgReceiveReply (confdb_inst->response_fd, iov, 1,
+ &res_lib_confdb_reload, sizeof (struct
res_lib_confdb_reload));
+
+ pthread_mutex_unlock (&confdb_inst->response_mutex);
+ if (error != SA_AIS_OK) {
+ goto error_exit;
+ }
+
+ error = res_lib_confdb_reload.header.error;
+ if(res_lib_confdb_reload.error.length)
+ memcpy(error_text, res_lib_confdb_reload.error.value,
res_lib_confdb_reload.error.length);
+
+error_exit:
+ saHandleInstancePut (&confdb_handle_t_db, handle);
+
+ return (error);
+}
+
+
Index: lib/sa-confdb.c
===================================================================
--- lib/sa-confdb.c (revision 1568)
+++ lib/sa-confdb.c (working copy)
@@ -284,7 +284,21 @@
return ret;
}
+int confdb_sa_reload (
+ unsigned int parent_object_handle,
+ int flush,
+ char *error_text)
+{
+ char *errtext;
+ int ret;
+ ret = objdb->object_reload_config(flush, &errtext);
+ if (!ret)
+ strcpy(error_text, errtext);
+
+ return ret;
+}
+
int confdb_sa_object_iter (
unsigned int parent_object_handle,
unsigned int start_pos,
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais