Ack.

Thanks,
Ramesh.

On 10/23/2013 6:46 PM, Hans Feldt wrote:
>   osaf/libs/core/leap/os_defs.c |  19 ++++++-------------
>   1 files changed, 6 insertions(+), 13 deletions(-)
>
>
> Now and then a test program fails with:
> os_defs.c:447: ncs_os_lock: Assertion `0' failed.
>
> Without core dumps enabled and a console printout this error will be invisible
> and undetected with hard to predict consequences.
>
> By changing ncs_os_lock to use the osaf_mutex_* utility functions, the pthread
> return code will be syslogged before the process is aborted (unconditionally)
>
> diff --git a/osaf/libs/core/leap/os_defs.c b/osaf/libs/core/leap/os_defs.c
> --- a/osaf/libs/core/leap/os_defs.c
> +++ b/osaf/libs/core/leap/os_defs.c
> @@ -409,11 +409,10 @@ void ncs_os_atomic_destroy(void)
>    
> ****************************************************************************/
>   unsigned int ncs_os_lock(NCS_OS_LOCK * lock, NCS_OS_LOCK_REQUEST request, 
> unsigned int type)
>   {
> -     volatile int rc;
> -     pthread_mutexattr_t mutex_attr;
> +     switch (request) {
> +     case NCS_OS_LOCK_CREATE: {
> +             pthread_mutexattr_t mutex_attr;
>   
> -     switch (request) {
> -     case NCS_OS_LOCK_CREATE:
>               if (pthread_mutexattr_init(&mutex_attr) != 0)
>                       return (NCSCC_RC_FAILURE);
>   
> @@ -429,24 +428,18 @@ unsigned int ncs_os_lock(NCS_OS_LOCK * l
>                       return (NCSCC_RC_FAILURE);
>   
>               break;
> -
> +     }
>       case NCS_OS_LOCK_RELEASE:
>               if (pthread_mutex_destroy(&lock->lock) != 0)
>                       return (NCSCC_RC_FAILURE);
>               break;
>   
>       case NCS_OS_LOCK_LOCK:
> -             if ((rc = pthread_mutex_lock(&lock->lock)) != 0) { /* get the 
> lock */
> -                     assert(0);
> -                     return (NCSCC_RC_FAILURE);
> -             }
> +             osaf_mutex_lock_ordie(&lock->lock);
>               break;
>   
>       case NCS_OS_LOCK_UNLOCK:
> -             if ((rc = pthread_mutex_unlock(&lock->lock)) != 0) { /* unlock 
> for all tasks */
> -                     assert(0);
> -                     return (NCSCC_RC_FAILURE);
> -             }
> +             osaf_mutex_unlock_ordie(&lock->lock);
>               break;
>   
>       default:


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to