diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-09-19 13:37:53 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-09-19 13:37:53 +0000 |
commit | 4b188d682a36a7fa454884ca55b5cf5a7bad069c (patch) | |
tree | c7f94ec4bd11263869fc2ed8804a7864a93a0591 /pjsip/include/pjsua-lib/pjsua_internal.h | |
parent | cf81bc0a2ab2947f4a2c5c5fd20bc77ea5611947 (diff) |
Fixed race-condition/deadlock problems in the dialog/user agent layer
all the way up to PJSUA-API:
- standardized locking order: dialog then user agent, and dialog then PJSUA
- any threads that attempt to acquire mutexes in different order than
above MUST employ retry mechanism (for an example, see acquire_call() in
pjsua_call.c). This retry mechanism has also been used in the UA layer
(sip_ua_layer.c) since it needs to lock user agent layer first before
the dialog.
- introduced pjsip_dlg_try_inc_lock() and PJSUA_TRY_LOCK() to accomodate
above.
- pjsua tested on Quad Xeon with 4 threads and 200 cps, so far so good.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@729 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include/pjsua-lib/pjsua_internal.h')
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua_internal.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h index 8b1002b4..10e76635 100644 --- a/pjsip/include/pjsua-lib/pjsua_internal.h +++ b/pjsip/include/pjsua-lib/pjsua_internal.h @@ -257,11 +257,13 @@ PJ_INLINE(pjsua_im_data*) pjsua_im_data_dup(pj_pool_t *pool, } -#if 0 -#define PJSUA_LOCK() pj_mutex_lock(pjsua_var.mutex); -#define PJSUA_UNLOCK() pj_mutex_unlock(pjsua_var.mutex); +#if 1 +#define PJSUA_LOCK() pj_mutex_lock(pjsua_var.mutex) +#define PJSUA_TRY_LOCK() pj_mutex_trylock(pjsua_var.mutex) +#define PJSUA_UNLOCK() pj_mutex_unlock(pjsua_var.mutex) #else #define PJSUA_LOCK() +#define PJSUA_TRY_LOCK() PJ_SUCCESS #define PJSUA_UNLOCK() #endif |