diff options
Diffstat (limited to 'main/astobj2.c')
-rw-r--r-- | main/astobj2.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c index 77f0f2962..212b64ed9 100644 --- a/main/astobj2.c +++ b/main/astobj2.c @@ -170,6 +170,21 @@ int _ao2_unlock(void *user_data, const char *file, const char *func, int line, c #endif } +int ao2_trylock(void *user_data) +{ + struct astobj2 *p = INTERNAL_OBJ(user_data); + int ret; + + if (p == NULL) + return -1; + ret = ast_mutex_trylock(&p->priv_data.lock); +#ifdef AO2_DEBUG + if (!ret) + ast_atomic_fetchadd_int(&ao2.total_locked, 1); +#endif + return ret; +} + /* * The argument is a pointer to the user portion. */ |