Remove ABI differences that occured when compiling with DEBUG_THREADS.
"Bad Things" would happen if Asterisk was compiled with DEBUG_THREADS, but a loaded module was not (or vice versa). This also immensely simplifies the lock code, since there are no longer 2 separate versions of them. Review: https://reviewboard.asterisk.org/r/508/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@258557 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
2b551e72e4
commit
8d07966e39
|
@ -472,12 +472,8 @@ int __ao2_ref(void *o, int delta);
|
|||
* \param a A pointer to the object we want to lock.
|
||||
* \return 0 on success, other values on error.
|
||||
*/
|
||||
#ifndef DEBUG_THREADS
|
||||
int ao2_lock(void *a);
|
||||
#else
|
||||
#define ao2_lock(a) __ao2_lock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
|
||||
int __ao2_lock(void *a, const char *file, const char *func, int line, const char *var);
|
||||
#endif
|
||||
#define ao2_lock(a) __ao2_lock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
|
||||
|
||||
/*! \brief
|
||||
* Unlock an object.
|
||||
|
@ -485,12 +481,8 @@ int __ao2_lock(void *a, const char *file, const char *func, int line, const char
|
|||
* \param a A pointer to the object we want unlock.
|
||||
* \return 0 on success, other values on error.
|
||||
*/
|
||||
#ifndef DEBUG_THREADS
|
||||
int ao2_unlock(void *a);
|
||||
#else
|
||||
#define ao2_unlock(a) __ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
|
||||
int __ao2_unlock(void *a, const char *file, const char *func, int line, const char *var);
|
||||
#endif
|
||||
#define ao2_unlock(a) __ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
|
||||
|
||||
/*! \brief
|
||||
* Try locking-- (don't block if fail)
|
||||
|
@ -498,12 +490,8 @@ int __ao2_unlock(void *a, const char *file, const char *func, int line, const ch
|
|||
* \param a A pointer to the object we want to lock.
|
||||
* \return 0 on success, other values on error.
|
||||
*/
|
||||
#ifndef DEBUG_THREADS
|
||||
int ao2_trylock(void *a);
|
||||
#else
|
||||
#define ao2_trylock(a) __ao2_trylock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
|
||||
int __ao2_trylock(void *a, const char *file, const char *func, int line, const char *var);
|
||||
#endif
|
||||
#define ao2_trylock(a) __ao2_trylock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
|
||||
|
||||
/*!
|
||||
* \brief Return the lock address of an object
|
||||
|
|
|
@ -209,8 +209,6 @@ void *ast_heap_peek(struct ast_heap *h, unsigned int index);
|
|||
*/
|
||||
size_t ast_heap_size(struct ast_heap *h);
|
||||
|
||||
#ifndef DEBUG_THREADS
|
||||
|
||||
/*!
|
||||
* \brief Write-Lock a heap
|
||||
*
|
||||
|
@ -223,7 +221,7 @@ size_t ast_heap_size(struct ast_heap *h);
|
|||
* \return see the documentation for pthread_rwlock_wrlock()
|
||||
* \since 1.6.1
|
||||
*/
|
||||
int ast_heap_wrlock(struct ast_heap *h);
|
||||
int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line);
|
||||
|
||||
/*!
|
||||
* \brief Read-Lock a heap
|
||||
|
@ -237,7 +235,7 @@ int ast_heap_wrlock(struct ast_heap *h);
|
|||
* \return see the documentation for pthread_rwlock_rdlock()
|
||||
* \since 1.6.1
|
||||
*/
|
||||
int ast_heap_rdlock(struct ast_heap *h);
|
||||
int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line);
|
||||
|
||||
/*!
|
||||
* \brief Unlock a heap
|
||||
|
@ -247,18 +245,11 @@ int ast_heap_rdlock(struct ast_heap *h);
|
|||
* \return see the documentation for pthread_rwlock_unlock()
|
||||
* \since 1.6.1
|
||||
*/
|
||||
int ast_heap_unlock(struct ast_heap *h);
|
||||
|
||||
#else /* DEBUG_THREADS */
|
||||
|
||||
#define ast_heap_wrlock(h) __ast_heap_wrlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line);
|
||||
#define ast_heap_rdlock(h) __ast_heap_rdlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line);
|
||||
#define ast_heap_unlock(h) __ast_heap_unlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line);
|
||||
|
||||
#endif /* DEBUG_THREADS */
|
||||
#define ast_heap_wrlock(h) __ast_heap_wrlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
#define ast_heap_rdlock(h) __ast_heap_rdlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
#define ast_heap_unlock(h) __ast_heap_unlock(h, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
|
||||
/*!
|
||||
* \brief Verify that a heap has been properly constructed
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -111,19 +111,11 @@ int ast_odbc_smart_execute(struct odbc_obj *obj, SQLHSTMT stmt) __attribute__((d
|
|||
* thread which requests it. Note that all connections should be released
|
||||
* when the thread is done by calling odbc_release_obj(), below.
|
||||
*/
|
||||
#ifdef DEBUG_THREADS
|
||||
struct odbc_obj *_ast_odbc_request_obj2(const char *name, struct ast_flags flags, const char *file, const char *function, int lineno);
|
||||
#define ast_odbc_request_obj2(a, b) _ast_odbc_request_obj2(a, b, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
#else
|
||||
struct odbc_obj *ast_odbc_request_obj2(const char *name, struct ast_flags flags);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_THREADS
|
||||
struct odbc_obj *_ast_odbc_request_obj(const char *name, int check, const char *file, const char *function, int lineno);
|
||||
|
||||
#define ast_odbc_request_obj2(a, b) _ast_odbc_request_obj2(a, b, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
#define ast_odbc_request_obj(a, b) _ast_odbc_request_obj(a, b, __FILE__, __PRETTY_FUNCTION__, __LINE__)
|
||||
#else
|
||||
struct odbc_obj *ast_odbc_request_obj(const char *name, int check);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Retrieve a stored ODBC object, if a transaction has been started.
|
||||
|
|
|
@ -143,11 +143,7 @@ static void *internal_ao2_callback(struct ao2_container *c,
|
|||
char *tag, char *file, int line, const char *funcname);
|
||||
static void *internal_ao2_iterator_next(struct ao2_iterator *a, struct bucket_list **q);
|
||||
|
||||
#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);
|
||||
|
||||
|
@ -158,18 +154,10 @@ 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_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);
|
||||
|
||||
|
@ -180,29 +168,17 @@ 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
|
||||
}
|
||||
|
||||
#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 ret;
|
||||
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
#ifndef DEBUG_THREADS
|
||||
ret = ast_mutex_trylock(&p->priv_data.lock);
|
||||
#else
|
||||
ret = __ast_pthread_mutex_trylock(file, line, func, var, &p->priv_data.lock);
|
||||
#endif
|
||||
|
||||
#ifdef AO2_DEBUG
|
||||
if (!ret)
|
||||
|
|
27
main/heap.c
27
main/heap.c
|
@ -302,38 +302,17 @@ size_t ast_heap_size(struct ast_heap *h)
|
|||
return h->cur_len;
|
||||
}
|
||||
|
||||
#ifndef DEBUG_THREADS
|
||||
|
||||
int ast_heap_wrlock(struct ast_heap *h)
|
||||
{
|
||||
return ast_rwlock_wrlock(&h->lock);
|
||||
}
|
||||
|
||||
int ast_heap_rdlock(struct ast_heap *h)
|
||||
{
|
||||
return ast_rwlock_rdlock(&h->lock);
|
||||
}
|
||||
|
||||
int ast_heap_unlock(struct ast_heap *h)
|
||||
{
|
||||
return ast_rwlock_unlock(&h->lock);
|
||||
}
|
||||
|
||||
#else /* DEBUG_THREADS */
|
||||
|
||||
int __ast_heap_wrlock(struct ast_heap *h, const char *file, const char *func, int line)
|
||||
{
|
||||
return _ast_rwlock_wrlock(&h->lock, "&h->lock", file, line, func);
|
||||
return __ast_rwlock_wrlock(&h->lock, "&h->lock", file, line, func);
|
||||
}
|
||||
|
||||
int __ast_heap_rdlock(struct ast_heap *h, const char *file, const char *func, int line)
|
||||
{
|
||||
return _ast_rwlock_rdlock(&h->lock, "&h->lock", file, line, func);
|
||||
return __ast_rwlock_rdlock(&h->lock, "&h->lock", file, line, func);
|
||||
}
|
||||
|
||||
int __ast_heap_unlock(struct ast_heap *h, const char *file, const char *func, int line)
|
||||
{
|
||||
return _ast_rwlock_unlock(&h->lock, "&h->lock", file, line, func);
|
||||
return __ast_rwlock_unlock(&h->lock, "&h->lock", file, line, func);
|
||||
}
|
||||
|
||||
#endif /* DEBUG_THREADS */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1150,11 +1150,7 @@ static int aoro2_obj_cb(void *vobj, void *arg, int flags)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_THREADS
|
||||
struct odbc_obj *_ast_odbc_request_obj2(const char *name, struct ast_flags flags, const char *file, const char *function, int lineno)
|
||||
#else
|
||||
struct odbc_obj *ast_odbc_request_obj2(const char *name, struct ast_flags flags)
|
||||
#endif
|
||||
{
|
||||
struct odbc_obj *obj = NULL;
|
||||
struct odbc_class *class;
|
||||
|
@ -1325,18 +1321,10 @@ struct odbc_obj *ast_odbc_request_obj2(const char *name, struct ast_flags flags)
|
|||
return obj;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_THREADS
|
||||
struct odbc_obj *_ast_odbc_request_obj(const char *name, int check, const char *file, const char *function, int lineno)
|
||||
#else
|
||||
struct odbc_obj *ast_odbc_request_obj(const char *name, int check)
|
||||
#endif
|
||||
{
|
||||
struct ast_flags flags = { check ? RES_ODBC_SANITY_CHECK : 0 };
|
||||
#ifdef DEBUG_THREADS
|
||||
return _ast_odbc_request_obj2(name, flags, file, function, lineno);
|
||||
#else
|
||||
return ast_odbc_request_obj2(name, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct odbc_obj *ast_odbc_retrieve_transaction_obj(struct ast_channel *chan, const char *objname)
|
||||
|
|
Reference in New Issue