From bba9b275750a70af970f7948aa02be7b9f737864 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 20 Oct 2004 22:55:53 +0000 Subject: [PATCH] - Be sure to unlock, even in error cases - Be sure to propagate errors upward in the case of copy_all() and delete_all() This commit was SVN r3249. --- src/attribute/attribute.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/attribute/attribute.c b/src/attribute/attribute.c index ef0474d97b..14f51cd737 100644 --- a/src/attribute/attribute.c +++ b/src/attribute/attribute.c @@ -43,6 +43,9 @@ ((ompi_##type##_t *)object, \ key, attribute, \ key_item->extra_state)) != MPI_SUCCESS) {\ + if (need_lock) { \ + OMPI_THREAD_UNLOCK(&alock); \ + } \ return err;\ } \ } @@ -58,6 +61,7 @@ if ((err = (*((hash_value->copy_attr_fn).attr_##type##_copy_fn)) \ ((ompi_##type##_t *)old_object, key, hash_value->extra_state, \ old_attr, &new_attr, &flag)) != MPI_SUCCESS) { \ + OMPI_THREAD_UNLOCK(&alock); \ return err; \ }\ } @@ -571,7 +575,7 @@ int ompi_attr_delete_all(ompi_attribute_type_t type, void *object, ompi_hash_table_t *keyhash) { - int ret; + int key_ret, del_ret; uint32_t key, oldkey; void *node, *in_node, *old_attr; @@ -594,10 +598,11 @@ ompi_attr_delete_all(ompi_attribute_type_t type, void *object, OMPI_THREAD_LOCK(&alock); /* Get the first key in local CWD hash */ - ret = ompi_hash_table_get_first_key_uint32(keyhash, + key_ret = ompi_hash_table_get_first_key_uint32(keyhash, &key, &old_attr, &node); - while (OMPI_SUCCESS == ret) { + del_ret = OMPI_SUCCESS; + while (OMPI_SUCCESS == key_ret && OMPI_SUCCESS == del_ret) { /* Save this node info for deletion, before we move onto the next node */ @@ -607,16 +612,16 @@ ompi_attr_delete_all(ompi_attribute_type_t type, void *object, /* Move to the next node */ - ret = ompi_hash_table_get_next_key_uint32(keyhash, - &key, &old_attr, - in_node, &node); + key_ret = ompi_hash_table_get_next_key_uint32(keyhash, + &key, &old_attr, + in_node, &node); /* Now delete this attribute */ - ompi_attr_delete(type, object, keyhash, oldkey, true, false); + del_ret = ompi_attr_delete(type, object, keyhash, oldkey, true, false); } /* All done */ OMPI_THREAD_UNLOCK(&alock); - return MPI_SUCCESS; + return del_ret; }