diff options
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index 5b0b0ba26..392aa09de 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -125,7 +125,11 @@ static inline struct astobj2 *INTERNAL_OBJ(void *user_data) */ #define EXTERNAL_OBJ(_p) ((_p) == NULL ? NULL : (_p)->user_data) +#ifndef DEBUG_THREADS +int ao2_lock(void *user_data) +#else int __ao2_lock(void *user_data, const char *file, const char *func, int line, const char *var) +#endif { struct astobj2 *p = INTERNAL_OBJ(user_data); @@ -136,10 +140,18 @@ int __ao2_lock(void *user_data, const char *file, const char *func, int line, co ast_atomic_fetchadd_int(&ao2.total_locked, 1); #endif +#ifndef DEBUG_THREADS + return ast_mutex_lock(&p->priv_data.lock); +#else return __ast_pthread_mutex_lock(file, line, func, var, &p->priv_data.lock); +#endif } +#ifndef DEBUG_THREADS +int ao2_trylock(void *user_data) +#else int __ao2_trylock(void *user_data, const char *file, const char *func, int line, const char *var) +#endif { struct astobj2 *p = INTERNAL_OBJ(user_data); int res; @@ -147,7 +159,11 @@ int __ao2_trylock(void *user_data, const char *file, const char *func, int line, if (p == NULL) return -1; +#ifndef DEBUG_THREADS + res = ast_mutex_trylock(&p->priv_data.lock); +#else res = __ast_pthread_mutex_trylock(file, line, func, var, &p->priv_data.lock); +#endif #ifdef AO2_DEBUG if (!res) { @@ -158,7 +174,11 @@ int __ao2_trylock(void *user_data, const char *file, const char *func, int line, return res; } +#ifndef DEBUG_THREADS +int ao2_unlock(void *user_data) +#else int __ao2_unlock(void *user_data, const char *file, const char *func, int line, const char *var) +#endif { struct astobj2 *p = INTERNAL_OBJ(user_data); @@ -169,7 +189,11 @@ int __ao2_unlock(void *user_data, const char *file, const char *func, int line, ast_atomic_fetchadd_int(&ao2.total_locked, -1); #endif +#ifndef DEBUG_THREADS + return ast_mutex_unlock(&p->priv_data.lock); +#else return __ast_pthread_mutex_unlock(file, line, func, var, &p->priv_data.lock); +#endif } /* |