From 98e98ce2c546cf0bcda9dfc82b6ea8104398b890 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Tue, 11 Oct 2011 18:43:45 +0000 Subject: [PATCH] * opal_atomic_trylock is documented to return 0 if the lock was acquired, 1 otherwise. It was doing the opposite, so this patch fixes the return values. All uses (all in ORTE) used the actual return values, not the documented values, so fix them as well. This commit was SVN r25257. --- opal/include/opal/sys/atomic_impl.h | 5 +++-- orte/mca/errmgr/default_hnp/errmgr_default_hnp.c | 2 +- orte/mca/errmgr/hnp/errmgr_hnp.c | 2 +- orte/mca/ess/hnp/ess_hnp_module.c | 2 +- orte/runtime/orte_finalize.c | 2 +- orte/runtime/orte_quit.c | 4 ++-- orte/runtime/orte_wait.c | 4 ++-- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/opal/include/opal/sys/atomic_impl.h b/opal/include/opal/sys/atomic_impl.h index 3c52da9a44..292b6156ff 100644 --- a/opal/include/opal/sys/atomic_impl.h +++ b/opal/include/opal/sys/atomic_impl.h @@ -357,8 +357,9 @@ opal_atomic_init( opal_atomic_lock_t* lock, int32_t value ) static inline int opal_atomic_trylock(opal_atomic_lock_t *lock) { - return opal_atomic_cmpset_acq_32( &(lock->u.lock), - OPAL_ATOMIC_UNLOCKED, OPAL_ATOMIC_LOCKED); + int ret = opal_atomic_cmpset_acq_32( &(lock->u.lock), + OPAL_ATOMIC_UNLOCKED, OPAL_ATOMIC_LOCKED); + return (ret == 0) ? 1 : 0; } diff --git a/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c b/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c index 60349aa48d..d90edeb8fa 100644 --- a/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c +++ b/orte/mca/errmgr/default_hnp/errmgr_default_hnp.c @@ -493,7 +493,7 @@ static void default_hnp_abort(orte_jobid_t job, orte_exit_code_t exit_code) int rc; /* if we are already in progress, then ignore this call */ - if (!opal_atomic_trylock(&orte_abort_inprogress_lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&orte_abort_inprogress_lock)) { /* returns 1 if already locked */ OPAL_OUTPUT_VERBOSE((1, orte_errmgr_base.output, "%s errmgr:default_hnp: abort in progress, ignoring abort on job %s with status %d", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), diff --git a/orte/mca/errmgr/hnp/errmgr_hnp.c b/orte/mca/errmgr/hnp/errmgr_hnp.c index 8bfcf10680..85d9d89128 100644 --- a/orte/mca/errmgr/hnp/errmgr_hnp.c +++ b/orte/mca/errmgr/hnp/errmgr_hnp.c @@ -1021,7 +1021,7 @@ static void hnp_abort(orte_jobid_t job, orte_exit_code_t exit_code) int rc; /* if we are already in progress, then ignore this call */ - if (!opal_atomic_trylock(&orte_abort_inprogress_lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&orte_abort_inprogress_lock)) { /* returns 1 if already locked */ OPAL_OUTPUT_VERBOSE((1, orte_errmgr_base.output, "%s errmgr:hnp: abort in progress, ignoring abort on job %s with status %d", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), diff --git a/orte/mca/ess/hnp/ess_hnp_module.c b/orte/mca/ess/hnp/ess_hnp_module.c index 726d8cb6d7..3f2e5b9c9b 100644 --- a/orte/mca/ess/hnp/ess_hnp_module.c +++ b/orte/mca/ess/hnp/ess_hnp_module.c @@ -1065,7 +1065,7 @@ static void abort_signal_callback(int fd, short flags, void *arg) /* if we have already ordered this once, don't keep * doing it to avoid race conditions */ - if (!opal_atomic_trylock(&orte_abort_inprogress_lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&orte_abort_inprogress_lock)) { /* returns 1 if already locked */ if (forcibly_die) { /* kill any local procs */ orte_odls.kill_local_procs(NULL); diff --git a/orte/runtime/orte_finalize.c b/orte/runtime/orte_finalize.c index 679831820d..7bf1e649fc 100644 --- a/orte/runtime/orte_finalize.c +++ b/orte/runtime/orte_finalize.c @@ -47,7 +47,7 @@ int orte_finalize(void) } /* protect against multiple calls */ - if (!opal_atomic_trylock(&orte_finalize_lock)) { + if (opal_atomic_trylock(&orte_finalize_lock)) { return ORTE_SUCCESS; } diff --git a/orte/runtime/orte_quit.c b/orte/runtime/orte_quit.c index dbbe35eb2f..c0e9c8c9fe 100644 --- a/orte/runtime/orte_quit.c +++ b/orte/runtime/orte_quit.c @@ -75,7 +75,7 @@ void orte_jobs_complete(void) { #if !ORTE_DISABLE_FULL_SUPPORT /* check one-time lock to protect against multiple calls */ - if (!opal_atomic_trylock(&orte_jobs_complete_lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&orte_jobs_complete_lock)) { /* returns 1 if already locked */ return; } @@ -139,7 +139,7 @@ void orte_jobs_complete(void) void orte_quit(void) { /* check one-time lock to protect against "bounce" */ - if (!opal_atomic_trylock(&orte_quit_lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&orte_quit_lock)) { /* returns 1 if already locked */ return; } diff --git a/orte/runtime/orte_wait.c b/orte/runtime/orte_wait.c index cb4f67667e..cb42ee02c6 100644 --- a/orte/runtime/orte_wait.c +++ b/orte/runtime/orte_wait.c @@ -538,7 +538,7 @@ void orte_trigger_event(orte_trigger_event_t *trig) /* if we already fired it, don't do it again - this automatically * records that we did fire it */ - if (!opal_atomic_trylock(&trig->lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&trig->lock)) { /* returns 1 if already locked */ return; } @@ -842,7 +842,7 @@ void orte_trigger_event(orte_trigger_event_t *trig) ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), trig->name)); - if (!opal_atomic_trylock(&trig->lock)) { /* returns 1 if already locked */ + if (opal_atomic_trylock(&trig->lock)) { /* returns 1 if already locked */ return; }