[Openais] [PATCH] add the missing confdb_key_delete function to the confdb API

Steven Dake sdake at redhat.com
Sun Aug 3 22:30:40 PDT 2008


merged.

thanks!
-steve
On Tue, 2008-07-29 at 08:25 +1200, angus salkeld wrote:
> ---
>  corosync/lib/Makefile    |    1 +
>  corosync/lib/confdb.c    |   58 ++++++++++++++++++++++++++++++++++++++++++++++
>  corosync/lib/sa-confdb.c |   12 +++++++++
>  corosync/lib/sa-confdb.h |    1 +
>  4 files changed, 72 insertions(+), 0 deletions(-)
> 
> diff --git a/corosync/lib/Makefile b/corosync/lib/Makefile
> index 5beddc3..7606744 100644
> --- a/corosync/lib/Makefile
> +++ b/corosync/lib/Makefile
> @@ -31,6 +31,7 @@
>  # Include configuration
>  #
>  srcdir ?= $(CURDIR)/../
> +subdir ?= lib/
>  
>  include $(srcdir)Makefile.inc
>  
> diff --git a/corosync/lib/confdb.c b/corosync/lib/confdb.c
> index 43174f4..7e22c03 100644
> --- a/corosync/lib/confdb.c
> +++ b/corosync/lib/confdb.c
> @@ -659,6 +659,64 @@ error_exit:
>  	return (error);
>  }
>  
> +confdb_error_t confdb_key_delete (
> +	confdb_handle_t handle,
> +	unsigned int parent_object_handle,
> +	void *key_name,
> +	int key_name_len,
> +	void *value,
> +	int value_len)
> +{
> +	confdb_error_t error;
> +	struct confdb_inst *confdb_inst;
> +	struct iovec iov[2];
> +	struct req_lib_confdb_key_delete req_lib_confdb_key_delete;
> +	mar_res_header_t res;
> +
> +	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_key_delete(parent_object_handle,
> +					 key_name, key_name_len,
> +					 value, value_len))
> +			error = SA_AIS_ERR_ACCESS;
> +		goto error_exit;
> +	}
> +
> +	req_lib_confdb_key_delete.header.size = sizeof (struct req_lib_confdb_key_delete);
> +	req_lib_confdb_key_delete.header.id = MESSAGE_REQ_CONFDB_KEY_DELETE;
> +	req_lib_confdb_key_delete.object_handle = parent_object_handle;
> +	memcpy(req_lib_confdb_key_delete.key_name.value, key_name, key_name_len);
> +	req_lib_confdb_key_delete.key_name.length = key_name_len;
> +	memcpy(req_lib_confdb_key_delete.value.value, value, value_len);
> +	req_lib_confdb_key_delete.value.length = value_len;
> +
> +	iov[0].iov_base = (char *)&req_lib_confdb_key_delete;
> +	iov[0].iov_len = sizeof (struct req_lib_confdb_key_delete);
> +
> +	pthread_mutex_lock (&confdb_inst->response_mutex);
> +
> +	error = saSendMsgReceiveReply (confdb_inst->response_fd, iov, 1,
> +		&res, sizeof (res));
> +
> +	pthread_mutex_unlock (&confdb_inst->response_mutex);
> +	if (error != SA_AIS_OK) {
> +		goto error_exit;
> +	}
> +
> +	error = res.error;
> +
> +error_exit:
> +	saHandleInstancePut (&confdb_handle_t_db, handle);
> +
> +	return (error);
> +}
> +
>  confdb_error_t confdb_key_get (
>  	confdb_handle_t handle,
>  	unsigned int parent_object_handle,
> diff --git a/corosync/lib/sa-confdb.c b/corosync/lib/sa-confdb.c
> index f54309e..d224bed 100644
> --- a/corosync/lib/sa-confdb.c
> +++ b/corosync/lib/sa-confdb.c
> @@ -219,6 +219,18 @@ int confdb_sa_key_create (
>  					value, value_len);
>  }
>  
> +int confdb_sa_key_delete (
> +	unsigned int parent_object_handle,
> +	void *key_name,
> +	int key_name_len,
> +	void *value,
> +	int value_len)
> +{
> +	return objdb->object_key_delete(parent_object_handle,
> +					key_name, key_name_len,
> +					value, value_len);
> +}
> +
>  int confdb_sa_key_get (
>  	unsigned int parent_object_handle,
>  	void *key_name,
> diff --git a/corosync/lib/sa-confdb.h b/corosync/lib/sa-confdb.h
> index e22555b..16f3883 100644
> --- a/corosync/lib/sa-confdb.h
> +++ b/corosync/lib/sa-confdb.h
> @@ -37,6 +37,7 @@ extern int confdb_sa_object_create(unsigned int parent_object_handle, void *obje
>  extern int confdb_sa_object_destroy(unsigned int object_handle);
>  extern int confdb_sa_object_parent_get(unsigned int object_handle, unsigned int *parent_object_handle);
>  extern int confdb_sa_key_create(unsigned int parent_object_handle, void *key_name, int key_name_len, void *value, int value_len);
> +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);



More information about the Openais mailing list