[Openais] [corosync] [patch] - hdb_handle_refcount_get - initialize and lock

Ryan O'Hara rohara at redhat.com
Wed Jun 24 08:44:55 PDT 2009


On Wed, Jun 24, 2009 at 04:00:55PM +0200, Jan Friesse wrote:
> hdb_handle_refcount_get uses handle without lock and do unlock. This
> shouldn't ever happend.

The hdb_handle_refcount_get call definitely needs the
hdb_database_lock (&handle_database->lock).

I definitely do not understand why we would call
db_create (handle_database) in this code, though.



> diff --git a/trunk/include/corosync/hdb.h b/trunk/include/corosync/hdb.h
> index 84cdc79..681ebe4 100644
> --- a/trunk/include/corosync/hdb.h
> +++ b/trunk/include/corosync/hdb.h
> @@ -348,6 +348,13 @@ static inline int hdb_handle_refcount_get (
>  
>  	int refcount = 0;
>  
> +	if (handle_database->first_run == 1) {
> +		handle_database->first_run = 0;
> +		hdb_create (handle_database);
> +	}
> +
> +	hdb_database_lock (&handle_database->lock);
> +
>  	if (handle >= handle_database->handle_count) {
>  		hdb_database_unlock (&handle_database->lock);
>  		errno = EBADF;

> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais


More information about the Openais mailing list