I've tested this. It works nicely. Thanks for the commit.

Ryan

On Wed, Apr 29, 2009 at 05:13:37PM -0700, Steven Dake wrote:
> the hdb_handle_get was taking a 0 handle and comparing it to an
> unallocated structure in alot of test cases.  Instead move the check for
> checking the handle code after the verification that the handle "could"
> exist in the hdb.

> Index: include/corosync/hdb.h
> ===================================================================
> --- include/corosync/hdb.h    (revision 2164)
> +++ include/corosync/hdb.h    (working copy)
> @@ -243,22 +243,22 @@
>  
>       hdb_database_lock (&handle_database->lock);
>  
> -     if (check != 0xffffffff &&
> -             check != handle_database->handles[handle].check) {
> -
> +     *instance = NULL;
> +     if (handle >= handle_database->handle_count) {
>               hdb_database_unlock (&handle_database->lock);
>               errno = EBADF;
>               return (-1);
>       }
>  
> -     *instance = NULL;
> -     if (handle >= handle_database->handle_count) {
> +     if (handle_database->handles[handle].state != HDB_HANDLE_STATE_ACTIVE) {
>               hdb_database_unlock (&handle_database->lock);
>               errno = EBADF;
>               return (-1);
>       }
>  
> -     if (handle_database->handles[handle].state != HDB_HANDLE_STATE_ACTIVE) {
> +     if (check != 0xffffffff &&
> +             check != handle_database->handles[handle].check) {
> +
>               hdb_database_unlock (&handle_database->lock);
>               errno = EBADF;
>               return (-1);
> @@ -281,6 +281,13 @@
>  
>       hdb_database_lock (&handle_database->lock);
>  
> +     if (handle >= handle_database->handle_count) {
> +             hdb_database_unlock (&handle_database->lock);
> +
> +             errno = EBADF;
> +             return (-1);
> +     }
> +
>       if (check != 0xffffffff &&
>               check != handle_database->handles[handle].check) {
>  
> @@ -313,6 +320,13 @@
>  
>       hdb_database_lock (&handle_database->lock);
>  
> +     if (handle >= handle_database->handle_count) {
> +             hdb_database_unlock (&handle_database->lock);
> +
> +             errno = EBADF;
> +             return (-1);
> +     }
> +
>       if (check != 0xffffffff &&
>               check != handle_database->handles[handle].check) {
>               hdb_database_unlock (&handle_database->lock);

> _______________________________________________
> Openais mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/openais
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to