mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-11 20:38:45 +00:00
add macros for explicit module usecount increment/decrement
remove unnecessary locking around setting usecount to zero git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6876 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -290,6 +290,18 @@ void ast_unregister_atexit(void (*func)(void));
|
|||||||
static struct localuser *localusers = NULL; \
|
static struct localuser *localusers = NULL; \
|
||||||
static int localusecnt = 0;
|
static int localusecnt = 0;
|
||||||
|
|
||||||
|
#define STANDARD_INCREMENT_USECOUNT \
|
||||||
|
ast_mutex_lock(&localuser_lock); \
|
||||||
|
localusecnt++; \
|
||||||
|
ast_mutex_unlock(&localuser_lock); \
|
||||||
|
ast_update_use_count();
|
||||||
|
|
||||||
|
#define STANDARD_DECREMENT_USECOUNT \
|
||||||
|
ast_mutex_lock(&localuser_lock); \
|
||||||
|
localusecnt--; \
|
||||||
|
ast_mutex_unlock(&localuser_lock); \
|
||||||
|
ast_update_use_count();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Add a localuser.
|
* \brief Add a localuser.
|
||||||
* \param u a pointer to a localuser struct
|
* \param u a pointer to a localuser struct
|
||||||
@@ -375,16 +387,16 @@ void ast_unregister_atexit(void (*func)(void));
|
|||||||
u = u->next; \
|
u = u->next; \
|
||||||
free(ul); \
|
free(ul); \
|
||||||
} \
|
} \
|
||||||
ast_mutex_unlock(&localuser_lock); \
|
|
||||||
localusecnt=0; \
|
localusecnt=0; \
|
||||||
|
ast_mutex_unlock(&localuser_lock); \
|
||||||
|
ast_update_use_count(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set the specfied integer to the current usecount.
|
* \brief Set the specfied integer to the current usecount.
|
||||||
* \param res the integer variable to set.
|
* \param res the integer variable to set.
|
||||||
*
|
*
|
||||||
* This macro sets the specfied integer variable to the local usecount. It
|
* This macro sets the specfied integer variable to the local usecount.
|
||||||
* handles all the necessary thread synchronization.
|
|
||||||
*
|
*
|
||||||
* <b>Sample Usage:</b>
|
* <b>Sample Usage:</b>
|
||||||
* \code
|
* \code
|
||||||
|
|||||||
Reference in New Issue
Block a user