mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 09:32:34 +00:00
make pthread mutexes nested.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5144 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e7dfa236ec
commit
353fb3dfbb
@ -40,22 +40,40 @@ struct mutex {
|
|||||||
|
|
||||||
mutex_status_t iax_mutex_create(mutex_t **mutex)
|
mutex_status_t iax_mutex_create(mutex_t **mutex)
|
||||||
{
|
{
|
||||||
|
mutex_status_t status = MUTEX_FAILURE;
|
||||||
|
#ifndef WIN32
|
||||||
|
pthread_mutexattr_t attr;
|
||||||
|
#endif
|
||||||
mutex_t *check = NULL;
|
mutex_t *check = NULL;
|
||||||
|
|
||||||
check = (mutex_t *)malloc(sizeof(**mutex));
|
check = (mutex_t *)malloc(sizeof(**mutex));
|
||||||
if (!check)
|
if (!check)
|
||||||
return MUTEX_FAILURE;
|
goto done;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
InitializeCriticalSection(&check->mutex);
|
InitializeCriticalSection(&check->mutex);
|
||||||
#else
|
#else
|
||||||
if (pthread_mutex_init(&check->mutex, NULL))
|
if (pthread_mutexattr_init(&attr))
|
||||||
return MUTEX_FAILURE;
|
goto done;
|
||||||
|
|
||||||
|
if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
if (pthread_mutex_init(&check->mutex, &attr))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
goto success;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
pthread_mutexattr_destroy(&mattr);
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
success:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*mutex = check;
|
*mutex = check;
|
||||||
|
status = MUTEX_SUCCESS;
|
||||||
|
|
||||||
return MUTEX_SUCCESS;
|
done:
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_status_t iax_mutex_destroy(mutex_t *mutex)
|
mutex_status_t iax_mutex_destroy(mutex_t *mutex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user