Remove the disliked *_from calls from the objdb and recast

the confdb library to use the new find_create/find_next/find_destroy API
calls instead.

I've kept the libcondfb API the same as before with the single change of
adding a confdb_object_find_destroy to tidy up the find handle after
use. If you don't call this then libcondfb will do it for you when
confdb_finalize is called.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1660 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Christine Caulfield 2008-08-26 07:34:22 +00:00
parent b56ce92fab
commit 2bab5b36cc
12 changed files with 281 additions and 287 deletions

View File

@ -117,9 +117,8 @@ void apidef_init (struct objdb_iface_ver0 *objdb) {
apidef_corosync_api_v1.object_iter = objdb->object_iter;
apidef_corosync_api_v1.object_key_iter = objdb->object_key_iter;
apidef_corosync_api_v1.object_parent_get = objdb->object_parent_get;
apidef_corosync_api_v1.object_name_get = objdb->object_name_get;
apidef_corosync_api_v1.object_dump = objdb->object_dump;
apidef_corosync_api_v1.object_find_from = objdb->object_find_from;
apidef_corosync_api_v1.object_iter_from = objdb->object_iter_from;
apidef_corosync_api_v1.object_key_iter_from = objdb->object_key_iter_from;
apidef_corosync_api_v1.object_track_start = objdb->object_track_start;
apidef_corosync_api_v1.object_track_stop = objdb->object_track_stop;

View File

@ -696,12 +696,13 @@ static int object_find_next (
object_instance = list_entry (list, struct object_instance,
child_list);
if ((object_instance->object_name_len ==
object_find_instance->object_len) &&
if (object_find_instance->object_len == 0 ||
((object_instance->object_name_len ==
object_find_instance->object_len) &&
(memcmp (object_instance->object_name,
object_find_instance->object_name,
object_find_instance->object_len) == 0)) {
(memcmp (object_instance->object_name,
object_find_instance->object_name,
object_find_instance->object_len) == 0))) {
found = 1;
break;
@ -1001,25 +1002,6 @@ static int _dump_object(struct object_instance *instance, FILE *file, int depth)
}
static int object_key_iter_reset(unsigned int object_handle)
{
unsigned int res;
struct object_instance *instance;
res = hdb_handle_get (&object_instance_database,
object_handle, (void *)&instance);
if (res != 0) {
goto error_exit;
}
instance->iter_key_list = &instance->key_head;
hdb_handle_put (&object_instance_database, object_handle);
return (0);
error_exit:
return (-1);
}
static int object_key_iter(unsigned int parent_object_handle,
void **key_name,
int *key_len,
@ -1064,163 +1046,6 @@ error_exit:
return (-1);
}
static int object_iter_reset(unsigned int parent_object_handle)
{
unsigned int res;
struct object_instance *instance;
res = hdb_handle_get (&object_instance_database,
parent_object_handle, (void *)&instance);
if (res != 0) {
goto error_exit;
}
instance->iter_list = &instance->child_head;
hdb_handle_put (&object_instance_database, parent_object_handle);
return (0);
error_exit:
return (-1);
}
static int object_iter(unsigned int parent_object_handle,
void **object_name,
int *name_len,
unsigned int *object_handle)
{
unsigned int res;
struct object_instance *instance;
struct object_instance *find_instance = NULL;
struct list_head *list;
unsigned int found = 0;
res = hdb_handle_get (&object_instance_database,
parent_object_handle, (void *)&instance);
if (res != 0) {
goto error_exit;
}
res = -ENOENT;
list = instance->iter_list->next;
if (list != &instance->child_head) {
find_instance = list_entry (list, struct object_instance,
child_list);
found = 1;
}
instance->iter_list = list;
if (found) {
*object_handle = find_instance->object_handle;
*object_name = find_instance->object_name;
*name_len = find_instance->object_name_len;
res = 0;
}
else {
res = -1;
}
return (res);
error_exit:
return (-1);
}
static int object_find_from(unsigned int parent_object_handle,
unsigned int start_pos,
void *object_name,
int object_name_len,
unsigned int *object_handle,
unsigned int *next_pos)
{
unsigned int res;
unsigned int pos = 0;
struct object_instance *instance;
struct object_instance *find_instance = NULL;
struct list_head *list;
unsigned int found = 0;
res = hdb_handle_get (&object_instance_database,
parent_object_handle, (void *)&instance);
if (res != 0) {
goto error_exit;
}
res = -ENOENT;
for (list = instance->child_head.next;
list != &instance->child_head; list = list->next) {
find_instance = list_entry (list, struct object_instance,
child_list);
if ((find_instance->object_name_len == object_name_len) &&
(memcmp (find_instance->object_name, object_name,
object_name_len) == 0)) {
if (pos++ == start_pos) {
found = 1;
break;
}
}
}
hdb_handle_put (&object_instance_database, parent_object_handle);
if (found) {
*object_handle = find_instance->object_handle;
res = 0;
}
*next_pos = pos;
return (res);
error_exit:
return (-1);
}
static int object_iter_from(unsigned int parent_object_handle,
unsigned int start_pos,
void **object_name,
int *name_len,
unsigned int *object_handle)
{
unsigned int res;
unsigned int pos = 0;
struct object_instance *instance;
struct object_instance *find_instance = NULL;
struct list_head *list;
unsigned int found = 0;
res = hdb_handle_get (&object_instance_database,
parent_object_handle, (void *)&instance);
if (res != 0) {
goto error_exit;
}
res = -ENOENT;
for (list = instance->child_head.next;
list != &instance->child_head; list = list->next) {
find_instance = list_entry (list, struct object_instance,
child_list);
if (pos++ == start_pos) {
found = 1;
break;
}
}
if (found) {
*object_handle = find_instance->object_handle;
*object_name = find_instance->object_name;
*name_len = find_instance->object_name_len;
res = 0;
}
else {
res = -1;
}
return (res);
error_exit:
return (-1);
}
static int object_key_iter_from(unsigned int parent_object_handle,
unsigned int start_pos,
void **key_name,
@ -1296,6 +1121,27 @@ static int object_parent_get(unsigned int object_handle,
return (0);
}
static int object_name_get(unsigned int object_handle,
char *object_name,
int *object_name_len)
{
struct object_instance *instance;
unsigned int res;
res = hdb_handle_get (&object_instance_database,
object_handle, (void *)&instance);
if (res != 0) {
return (res);
}
memcpy(object_name, instance->object_name, instance->object_name_len);
*object_name_len = instance->object_name_len;
hdb_handle_put (&object_instance_database, object_handle);
return (0);
}
static int object_track_start(unsigned int object_handle,
object_track_depth_t depth,
@ -1449,16 +1295,12 @@ struct objdb_iface_ver0 objdb_iface = {
.object_find_create = object_find_create,
.object_find_next = object_find_next,
.object_find_destroy = object_find_destroy,
.object_find_from = object_find_from,
.object_key_get = object_key_get,
.object_key_iter = object_key_iter,
.object_key_iter_reset = object_key_iter_reset,
.object_key_iter_from = object_key_iter_from,
.object_iter = object_iter,
.object_iter_reset = object_iter_reset,
.object_iter_from = object_iter_from,
.object_priv_get = object_priv_get,
.object_parent_get = object_parent_get,
.object_name_get = object_name_get,
.object_track_start = object_track_start,
.object_track_stop = object_track_stop,
.object_dump = object_dump,

View File

@ -240,6 +240,10 @@ confdb_error_t confdb_object_find (
int object_name_len,
unsigned int *object_handle);
confdb_error_t confdb_object_find_destroy(
confdb_handle_t handle,
unsigned int parent_object_handle);
confdb_error_t confdb_object_iter_start (
confdb_handle_t handle,
unsigned int parent_object_handle);
@ -251,6 +255,10 @@ confdb_error_t confdb_object_iter (
void *object_name,
int *object_name_len);
confdb_error_t confdb_object_iter_destroy(
confdb_handle_t handle,
unsigned int parent_object_handle);
/*
* Key iterator
*/

View File

@ -245,25 +245,15 @@ struct corosync_api_v1 {
unsigned int object_handle,
unsigned int *parent_handle);
int (*object_name_get) (
unsigned int object_handle,
char *object_name,
int *object_name_len);
int (*object_dump) (
unsigned int object_handle,
FILE *file);
int (*object_find_from) (
unsigned int parent_object_handle,
unsigned int start_pos,
void *object_name,
int object_name_len,
unsigned int *object_handle,
unsigned int *next_pos);
int (*object_iter_from) (
unsigned int parent_object_handle,
unsigned int start_pos,
void **object_name,
int *name_len,
unsigned int *object_handle);
int (*object_key_iter_from) (
unsigned int parent_object_handle,
unsigned int start_pos,

View File

@ -175,25 +175,15 @@ struct objdb_iface_ver0 {
unsigned int object_handle,
unsigned int *parent_handle);
int (*object_name_get) (
unsigned int object_handle,
char *object_name,
int *object_name_len);
int (*object_dump) (
unsigned int object_handle,
FILE *file);
int (*object_find_from) (
unsigned int parent_object_handle,
unsigned int start_pos,
void *object_name,
int object_name_len,
unsigned int *object_handle,
unsigned int *next_pos);
int (*object_iter_from) (
unsigned int parent_object_handle,
unsigned int start_pos,
void **object_name,
int *name_len,
unsigned int *object_handle);
int (*object_key_iter_from) (
unsigned int parent_object_handle,
unsigned int start_pos,

View File

@ -52,7 +52,8 @@ enum req_confdb_types {
MESSAGE_REQ_CONFDB_TRACK_START = 10,
MESSAGE_REQ_CONFDB_TRACK_STOP = 11,
MESSAGE_REQ_CONFDB_WRITE = 12,
MESSAGE_REQ_CONFDB_RELOAD = 13
MESSAGE_REQ_CONFDB_RELOAD = 13,
MESSAGE_REQ_CONFDB_OBJECT_FIND_DESTROY = 14
};
enum res_confdb_types {
@ -72,7 +73,8 @@ enum res_confdb_types {
MESSAGE_RES_CONFDB_OBJECT_CREATE_CALLBACK = 13,
MESSAGE_RES_CONFDB_OBJECT_DESTROY_CALLBACK = 14,
MESSAGE_RES_CONFDB_WRITE = 15,
MESSAGE_RES_CONFDB_RELOAD = 16
MESSAGE_RES_CONFDB_RELOAD = 16,
MESSAGE_RES_CONFDB_OBJECT_FIND_DESTROY = 17
};
@ -129,25 +131,26 @@ struct req_lib_confdb_object_find {
mar_req_header_t header __attribute__((aligned(8)));
mar_uint32_t parent_object_handle __attribute__((aligned(8)));
mar_name_t object_name __attribute__((aligned(8)));
mar_uint32_t next_entry __attribute__((aligned(8)));
mar_uint32_t find_handle __attribute__((aligned(8)));
};
struct res_lib_confdb_object_find {
mar_res_header_t header __attribute__((aligned(8)));
mar_uint32_t object_handle __attribute__((aligned(8)));
mar_uint32_t next_entry __attribute__((aligned(8)));
mar_uint32_t find_handle __attribute__((aligned(8)));
};
struct req_lib_confdb_object_iter {
mar_req_header_t header __attribute__((aligned(8)));
mar_uint32_t parent_object_handle __attribute__((aligned(8)));
mar_uint32_t next_entry __attribute__((aligned(8)));
mar_uint32_t find_handle __attribute__((aligned(8)));
};
struct res_lib_confdb_object_iter {
mar_res_header_t header __attribute__((aligned(8)));
mar_name_t object_name __attribute__((aligned(8)));
mar_uint32_t object_handle __attribute__((aligned(8)));
mar_uint32_t find_handle __attribute__((aligned(8)));
};
struct req_lib_confdb_key_iter {
@ -168,6 +171,11 @@ struct req_lib_confdb_key_get {
mar_name_t key_name __attribute__((aligned(8)));
};
struct req_lib_confdb_object_find_destroy {
mar_req_header_t header __attribute__((aligned(8)));
mar_uint32_t find_handle __attribute__((aligned(8)));
};
struct res_lib_confdb_key_get {
mar_res_header_t header __attribute__((aligned(8)));
mar_name_t value __attribute__((aligned(8)));

View File

@ -57,7 +57,8 @@
struct iter_context {
struct list_head list;
uint32_t parent_object_handle;
uint32_t context;
uint32_t find_handle;
uint32_t next_entry;
};
struct confdb_inst {
@ -84,8 +85,12 @@ static struct saHandleDatabase confdb_handle_t_db = {
.handleInstanceDestructor = confdb_instance_destructor
};
static confdb_error_t do_find_destroy(struct confdb_inst *confdb_inst, unsigned int find_handle);
/* Safely tidy one iterator context list */
static void free_context_list(struct list_head *list)
static void free_context_list(struct confdb_inst *confdb_inst, struct list_head *list)
{
struct iter_context *context;
struct list_head *iter, *tmp;
@ -94,6 +99,7 @@ static void free_context_list(struct list_head *list)
iter != list; iter = tmp, tmp = iter->next) {
context = list_entry (iter, struct iter_context, list);
do_find_destroy(confdb_inst, context->find_handle);
free(context);
}
}
@ -210,9 +216,9 @@ confdb_error_t confdb_finalize (
saHandleDestroy (&confdb_handle_t_db, handle);
/* Free saved context handles */
free_context_list(&confdb_inst->object_find_head);
free_context_list(&confdb_inst->object_iter_head);
free_context_list(&confdb_inst->key_iter_head);
free_context_list(confdb_inst, &confdb_inst->object_find_head);
free_context_list(confdb_inst, &confdb_inst->object_iter_head);
free_context_list(confdb_inst, &confdb_inst->key_iter_head);
if (!confdb_inst->standalone) {
/*
@ -623,6 +629,99 @@ error_exit:
return (error);
}
static confdb_error_t do_find_destroy(
struct confdb_inst *confdb_inst,
unsigned int find_handle)
{
confdb_error_t error;
struct iovec iov[2];
struct req_lib_confdb_object_find_destroy req_lib_confdb_object_find_destroy;
mar_res_header_t res;
if (!find_handle)
return SA_AIS_OK;
if (confdb_inst->standalone) {
error = SA_AIS_OK;
if (confdb_sa_find_destroy(find_handle))
error = SA_AIS_ERR_ACCESS;
goto error_exit;
}
req_lib_confdb_object_find_destroy.header.size = sizeof (struct req_lib_confdb_object_find_destroy);
req_lib_confdb_object_find_destroy.header.id = MESSAGE_REQ_CONFDB_OBJECT_FIND_DESTROY;
req_lib_confdb_object_find_destroy.find_handle = find_handle;
iov[0].iov_base = (char *)&req_lib_confdb_object_find_destroy;
iov[0].iov_len = sizeof (struct req_lib_confdb_object_find_destroy);
pthread_mutex_lock (&confdb_inst->response_mutex);
error = saSendMsgReceiveReply (confdb_inst->response_fd, iov, 1,
&res, sizeof (mar_res_header_t));
pthread_mutex_unlock (&confdb_inst->response_mutex);
if (error != SA_AIS_OK) {
goto error_exit;
}
error = res.error;
error_exit:
return (error);
}
confdb_error_t object_find_destroy(
confdb_handle_t handle,
unsigned int parent_object_handle)
{
struct iter_context *context;
confdb_error_t error;
struct confdb_inst *confdb_inst;
error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
if (error != SA_AIS_OK) {
return (error);
}
context = find_iter_context(&confdb_inst->object_find_head, parent_object_handle);
error = do_find_destroy(confdb_inst, context->find_handle);
if (error == SA_AIS_OK) {
list_del(&context->list);
free(context);
}
saHandleInstancePut (&confdb_handle_t_db, handle);
return error;
}
confdb_error_t object_iter_destroy(
confdb_handle_t handle,
unsigned int parent_object_handle)
{
struct iter_context *context;
confdb_error_t error;
struct confdb_inst *confdb_inst;
error = saHandleInstanceGet (&confdb_handle_t_db, handle, (void *)&confdb_inst);
if (error != SA_AIS_OK) {
return (error);
}
context = find_iter_context(&confdb_inst->object_iter_head, parent_object_handle);
error = do_find_destroy(confdb_inst, context->find_handle);
if (error == SA_AIS_OK) {
list_del(&context->list);
free(context);
}
saHandleInstancePut (&confdb_handle_t_db, handle);
return error;
}
confdb_error_t confdb_key_create (
confdb_handle_t handle,
unsigned int parent_object_handle,
@ -883,10 +982,15 @@ confdb_error_t confdb_object_iter_start (
goto ret;
}
context->parent_object_handle = object_handle;
context->find_handle = 0;
list_add(&context->list, &confdb_inst->object_iter_head);
}
context->context = 0;
/* Start a new find context */
if (context->find_handle) {
do_find_destroy(confdb_inst, context->find_handle);
context->find_handle = 0;
}
saHandleInstancePut (&confdb_handle_t_db, handle);
@ -918,7 +1022,8 @@ confdb_error_t confdb_key_iter_start (
list_add(&context->list, &confdb_inst->key_iter_head);
}
context->context = 0;
context->find_handle = 0;
context->next_entry = 0;
saHandleInstancePut (&confdb_handle_t_db, handle);
@ -946,11 +1051,15 @@ confdb_error_t confdb_object_find_start (
error = CONFDB_ERR_NO_MEMORY;
goto ret;
}
context->find_handle = 0;
context->parent_object_handle = parent_object_handle;
list_add(&context->list, &confdb_inst->object_find_head);
}
context->context = 0;
/* Start a new find context */
if (context->find_handle) {
do_find_destroy(confdb_inst, context->find_handle);
context->find_handle = 0;
}
saHandleInstancePut (&confdb_handle_t_db, handle);
@ -988,10 +1097,10 @@ confdb_error_t confdb_object_find (
error = SA_AIS_OK;
if (confdb_sa_object_find(parent_object_handle,
context->context,
object_name, object_name_len,
&context->find_handle,
object_handle,
&context->context))
object_name, &object_name_len,
0))
error = SA_AIS_ERR_ACCESS;
goto error_exit;
}
@ -999,7 +1108,7 @@ confdb_error_t confdb_object_find (
req_lib_confdb_object_find.header.size = sizeof (struct req_lib_confdb_object_find);
req_lib_confdb_object_find.header.id = MESSAGE_REQ_CONFDB_OBJECT_FIND;
req_lib_confdb_object_find.parent_object_handle = parent_object_handle;
req_lib_confdb_object_find.next_entry = context->context;
req_lib_confdb_object_find.find_handle = context->find_handle;
memcpy(req_lib_confdb_object_find.object_name.value, object_name, object_name_len);
req_lib_confdb_object_find.object_name.length = object_name_len;
@ -1018,7 +1127,7 @@ confdb_error_t confdb_object_find (
error = res_lib_confdb_object_find.header.error;
*object_handle = res_lib_confdb_object_find.object_handle;
context->context = res_lib_confdb_object_find.next_entry;
context->find_handle = res_lib_confdb_object_find.find_handle;
error_exit:
saHandleInstancePut (&confdb_handle_t_db, handle);
@ -1056,10 +1165,12 @@ confdb_error_t confdb_object_iter (
if (confdb_inst->standalone) {
error = SA_AIS_OK;
if (confdb_sa_object_iter(parent_object_handle,
context->context,
*object_name_len = 0;
if (confdb_sa_object_find(parent_object_handle,
&context->find_handle,
object_handle,
object_name, object_name_len))
object_name, object_name_len,
1))
error = SA_AIS_ERR_ACCESS;
goto sa_exit;
}
@ -1067,7 +1178,7 @@ confdb_error_t confdb_object_iter (
req_lib_confdb_object_iter.header.size = sizeof (struct req_lib_confdb_object_iter);
req_lib_confdb_object_iter.header.id = MESSAGE_REQ_CONFDB_OBJECT_ITER;
req_lib_confdb_object_iter.parent_object_handle = parent_object_handle;
req_lib_confdb_object_iter.next_entry = context->context;
req_lib_confdb_object_iter.find_handle = context->find_handle;
iov[0].iov_base = (char *)&req_lib_confdb_object_iter;
iov[0].iov_len = sizeof (struct req_lib_confdb_object_iter);
@ -1087,9 +1198,9 @@ confdb_error_t confdb_object_iter (
*object_name_len = res_lib_confdb_object_iter.object_name.length;
memcpy(object_name, res_lib_confdb_object_iter.object_name.value, *object_name_len);
*object_handle = res_lib_confdb_object_iter.object_handle;
context->find_handle = res_lib_confdb_object_iter.find_handle;
}
sa_exit:
context->context++;
error_exit:
saHandleInstancePut (&confdb_handle_t_db, handle);
@ -1128,7 +1239,7 @@ confdb_error_t confdb_key_iter (
error = SA_AIS_OK;
if (confdb_sa_key_iter(parent_object_handle,
context->context,
context->next_entry,
key_name, key_name_len,
value, value_len))
error = SA_AIS_ERR_ACCESS;
@ -1138,7 +1249,7 @@ confdb_error_t confdb_key_iter (
req_lib_confdb_key_iter.header.size = sizeof (struct req_lib_confdb_key_iter);
req_lib_confdb_key_iter.header.id = MESSAGE_REQ_CONFDB_KEY_ITER;
req_lib_confdb_key_iter.parent_object_handle = parent_object_handle;
req_lib_confdb_key_iter.next_entry = context->context;
req_lib_confdb_key_iter.next_entry= context->next_entry;
iov[0].iov_base = (char *)&req_lib_confdb_key_iter;
iov[0].iov_len = sizeof (struct req_lib_confdb_key_iter);
@ -1162,7 +1273,7 @@ confdb_error_t confdb_key_iter (
}
sa_exit:
context->context++;
context->next_entry++;
error_exit:
saHandleInstancePut (&confdb_handle_t_db, handle);

View File

@ -266,22 +266,6 @@ int confdb_sa_key_replace (
new_value, new_value_len);
}
int confdb_sa_object_find (
unsigned int parent_object_handle,
unsigned int start_pos,
void *object_name,
int object_name_len,
unsigned int *object_handle,
unsigned int *next_pos)
{
return objdb->object_find_from(parent_object_handle,
start_pos,
object_name,
object_name_len,
object_handle,
next_pos);
}
int confdb_sa_write (
unsigned int parent_object_handle,
char *error_text)
@ -311,22 +295,28 @@ int confdb_sa_reload (
return ret;
}
int confdb_sa_object_iter (
int confdb_sa_object_find (
unsigned int parent_object_handle,
unsigned int start_pos,
unsigned int *find_handle,
unsigned int *object_handle,
void *object_name,
int *object_name_len)
int *object_name_len,
int copy_name)
{
int res;
void *objname;
res = objdb->object_iter_from(parent_object_handle,
start_pos,
&objname, object_name_len,
if (!*find_handle) {
objdb->object_find_create(parent_object_handle,
object_name, *object_name_len,
find_handle);
}
res = objdb->object_find_next(*find_handle,
object_handle);
if (!res) {
memcpy(object_name, objname, *object_name_len);
/* Return object name if we were called as _iter */
if (copy_name && !res) {
objdb->object_name_get(*object_handle,
object_name, object_name_len);
}
return res;
}
@ -353,3 +343,8 @@ int confdb_sa_key_iter (
}
return res;
}
int confdb_sa_find_destroy(unsigned int find_handle)
{
return objdb->object_find_destroy(find_handle);
}

View File

@ -40,8 +40,8 @@ extern int confdb_sa_key_create(unsigned int parent_object_handle, void *key_nam
extern int confdb_sa_key_delete(unsigned int parent_object_handle, void *key_name, int key_name_len, void *value, int value_len);
extern int confdb_sa_key_get(unsigned int parent_object_handle, void *key_name, int key_name_len, void *value, int *value_len);
extern int confdb_sa_key_replace(unsigned int parent_object_handle, void *key_name, int key_name_len, void *old_value, int old_value_len, void *new_value, int new_value_len);
extern int confdb_sa_object_find(unsigned int parent_object_handle, unsigned int start_pos, void *object_name, int object_name_len, unsigned int *object_handle, unsigned int *next_pos);
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_object_find(unsigned int parent_object_handle, unsigned int *find_handle, unsigned int *object_handle, void *object_name, int *object_name_len, int copy_name);
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_find_destroy(unsigned int find_handle);
extern int confdb_sa_write(char *error_text);
extern int confdb_sa_reload(int flush, char *error_text);

View File

@ -40,6 +40,8 @@ confdb_object_find \- Find a named object in the Configuration Database
.BI "confdb_error_t confdb_object_find_start(confdb_handle_t " handle ", unsigned int " parent_object_handle " ); "
.sp
.BI "confdb_error_t confdb_object_find(confdb_handle_t " handle ", unsigned int " parent_object_handle ", void " *object_name ", int " object_name_len ", unsigned int " *object_handle " ); "
.sp
.BI "confdb_error_t confdb_object_find_destroy(confdb_handle_t " handle ", unsigned int " parent_object_handle " ); "
.SH DESCRIPTION
The
@ -60,6 +62,10 @@ The library holds a seperate context for each parent object, so you can call con
or
.B confdb_key_iter
calls on the same parent object.
.BR
.B When you have finished searching for objects, call the
.B confdb_object_find_destroy
library call to free up memory associated with the search context.
.SH RETURN VALUE
This call returns the CONFDB_OK value if successful, otherwise an error is returned.
.PP

View File

@ -40,6 +40,8 @@ confdb_object_iter \- Iterate through objects in the Configuration Database
.BI "confdb_error_t confdb_object_iter_start(confdb_handle_t " handle ", unsigned int " parent_object_handle " ); "
.sp
.BI "confdb_error_t confdb_object_iter(confdb_handle_t " handle ", unsigned int " parent_object_handle ", unsigned int " *object_handle ", void " *object_name ", int " *object_name_len " ); "
.sp
.BI "confdb_error_t confdb_object_iter_destroy(confdb_handle_t " handle ", unsigned int " parent_object_handle " ); "
.SH DESCRIPTION
The
@ -51,6 +53,10 @@ first. This establishes a context for the parent object so that it knows where y
will return the handle of the first object in the list. Subsequent calls will return any remaining objects. The function returns CONFDB_ERR_ACCESS when the all of the matching objects have been seen. The function returns the name and length of the object as well
as its handle.
.BR
.B When you have finished searching for objects, call the
.B confdb_object_iter_destroy
library call to free up memory associated with the search context.
.BR
.BR
.SH RETURN VALUE
This call returns the CONFDB_OK value if successful, otherwise an error is returned.

View File

@ -61,6 +61,7 @@ static int confdb_lib_exit_fn (void *conn);
static void message_handler_req_lib_confdb_object_create (void *conn, void *message);
static void message_handler_req_lib_confdb_object_destroy (void *conn, void *message);
static void message_handler_req_lib_confdb_object_find_destroy (void *conn, void *message);
static void message_handler_req_lib_confdb_key_create (void *conn, void *message);
static void message_handler_req_lib_confdb_key_get (void *conn, void *message);
@ -182,6 +183,12 @@ static struct corosync_lib_handler confdb_lib_engine[] =
.response_id = MESSAGE_RES_CONFDB_RELOAD,
.flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
},
{ /* 14 */
.lib_handler_fn = message_handler_req_lib_confdb_object_find_destroy,
.response_size = sizeof (mar_res_header_t),
.response_id = MESSAGE_RES_CONFDB_OBJECT_FIND_DESTROY,
.flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED
},
};
@ -252,7 +259,6 @@ static int confdb_lib_init_fn (void *conn)
static int confdb_lib_exit_fn (void *conn)
{
log_printf(LOG_LEVEL_DEBUG, "exit_fn for conn=%p\n", conn);
/* cleanup the object trackers for this client. */
api->object_track_stop(confdb_notify_lib_of_key_change,
@ -292,7 +298,24 @@ static void message_handler_req_lib_confdb_object_destroy (void *conn, void *mes
ret = SA_AIS_ERR_ACCESS;
res.size = sizeof(res);
res.id = MESSAGE_RES_CONFDB_OBJECT_CREATE;
res.id = MESSAGE_RES_CONFDB_OBJECT_DESTROY;
res.error = ret;
api->ipc_conn_send_response(conn, &res, sizeof(res));
}
static void message_handler_req_lib_confdb_object_find_destroy (void *conn, void *message)
{
struct req_lib_confdb_object_find_destroy *req_lib_confdb_object_find_destroy = (struct req_lib_confdb_object_find_destroy *)message;
mar_res_header_t res;
int ret = SA_AIS_OK;
log_printf(LOG_LEVEL_DEBUG, "object_find_destroy for conn=%p, %d\n", conn, req_lib_confdb_object_find_destroy->find_handle);
if (api->object_find_destroy(req_lib_confdb_object_find_destroy->find_handle))
ret = SA_AIS_ERR_ACCESS;
res.size = sizeof(res);
res.id = MESSAGE_RES_CONFDB_OBJECT_FIND_DESTROY;
res.error = ret;
api->ipc_conn_send_response(conn, &res, sizeof(res));
}
@ -435,19 +458,26 @@ static void message_handler_req_lib_confdb_object_iter (void *conn, void *messag
{
struct req_lib_confdb_object_iter *req_lib_confdb_object_iter = (struct req_lib_confdb_object_iter *)message;
struct res_lib_confdb_object_iter res_lib_confdb_object_iter;
void *object_name;
int object_name_len;
int ret = SA_AIS_OK;
if (api->object_iter_from(req_lib_confdb_object_iter->parent_object_handle,
req_lib_confdb_object_iter->next_entry,
&object_name,
&object_name_len,
&res_lib_confdb_object_iter.object_handle))
if (!req_lib_confdb_object_iter->find_handle) {
api->object_find_create(req_lib_confdb_object_iter->parent_object_handle,
NULL, 0,
&res_lib_confdb_object_iter.find_handle);
}
else
res_lib_confdb_object_iter.find_handle = req_lib_confdb_object_iter->find_handle;
if (api->object_find_next(res_lib_confdb_object_iter.find_handle,
&res_lib_confdb_object_iter.object_handle))
ret = SA_AIS_ERR_ACCESS;
else {
api->object_name_get(res_lib_confdb_object_iter.object_handle,
(char *)res_lib_confdb_object_iter.object_name.value,
&object_name_len);
res_lib_confdb_object_iter.object_name.length = object_name_len;
memcpy(res_lib_confdb_object_iter.object_name.value, object_name, object_name_len);
}
res_lib_confdb_object_iter.header.size = sizeof(res_lib_confdb_object_iter);
res_lib_confdb_object_iter.header.id = MESSAGE_RES_CONFDB_OBJECT_ITER;
@ -462,18 +492,24 @@ static void message_handler_req_lib_confdb_object_find (void *conn, void *messag
struct res_lib_confdb_object_find res_lib_confdb_object_find;
int ret = SA_AIS_OK;
if (api->object_find_from(req_lib_confdb_object_find->parent_object_handle,
req_lib_confdb_object_find->next_entry,
req_lib_confdb_object_find->object_name.value,
req_lib_confdb_object_find->object_name.length,
&res_lib_confdb_object_find.object_handle,
&res_lib_confdb_object_find.next_entry))
if (!req_lib_confdb_object_find->find_handle) {
api->object_find_create(req_lib_confdb_object_find->parent_object_handle,
req_lib_confdb_object_find->object_name.value,
req_lib_confdb_object_find->object_name.length,
&res_lib_confdb_object_find.find_handle);
}
else
res_lib_confdb_object_find.find_handle = req_lib_confdb_object_find->find_handle;
if (api->object_find_next(res_lib_confdb_object_find.find_handle,
&res_lib_confdb_object_find.object_handle))
ret = SA_AIS_ERR_ACCESS;
res_lib_confdb_object_find.header.size = sizeof(res_lib_confdb_object_find);
res_lib_confdb_object_find.header.id = MESSAGE_RES_CONFDB_OBJECT_FIND;
res_lib_confdb_object_find.header.error = ret;
api->ipc_conn_send_response(conn, &res_lib_confdb_object_find, sizeof(res_lib_confdb_object_find));
}
@ -618,3 +654,6 @@ static void message_handler_req_lib_confdb_track_stop (void *conn, void *message
}