Changeset 320 for trunk/include


Ignore:
Timestamp:
Mar 15, 2011, 8:59:48 PM (14 years ago)
Author:
katerina
Message:

Fix for ticket #237: Potential deadlock in sh_hash_hashdelete()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/sh_pthread.h

    r315 r320  
    2323        do {                                                               \
    2424                int oldtype;                                               \
     25                int executeStack = 1;                                      \
    2526                pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);  \
    2627                pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\
    2728                pthread_mutex_lock(&(M))
    2829
     30#define SH_MUTEX_TRYLOCK(M)                                                \
     31        do {                                                               \
     32                int oldtype;                                               \
     33                int executeStack = 0;                                      \
     34                pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype);  \
     35                pthread_cleanup_push(sh_pthread_mutex_unlock, (void*)&(M));\
     36                pthread_mutex_trylock(&(M));                               \
     37                executeStack = 1
    2938
    3039#define SH_MUTEX_UNLOCK(M)                                                 \
    31                 pthread_cleanup_pop(1);                                    \
     40                pthread_cleanup_pop(executeStack);                         \
    3241                pthread_setcanceltype(oldtype, NULL);                      \
    3342        } while (0)
     
    147156#define SH_MUTEX_EXTERN(M)                      extern void *SH_MUTEX_DUMMY_ ## M
    148157#define SH_MUTEX_LOCK(M)                        ((void)0)
     158#define SH_MUTEX_TRYLOCK(M)                     ((void)0)
    149159#define SH_MUTEX_UNLOCK(M)                      ((void)0)
    150160#define SH_MUTEX_LOCK_UNSAFE(M)                 ((void)0)
Note: See TracChangeset for help on using the changeset viewer.