projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merged from silc_1_0_branch.
[silc.git]
/
lib
/
silcutil
/
unix
/
silcunixmutex.c
diff --git
a/lib/silcutil/unix/silcunixmutex.c
b/lib/silcutil/unix/silcunixmutex.c
index 6b92ee3286d7a6c56cc79cee37607639e7f61aa4..d6eb0f233f973dd63e51d183b29b5ad577fb4696 100644
(file)
--- a/
lib/silcutil/unix/silcunixmutex.c
+++ b/
lib/silcutil/unix/silcunixmutex.c
@@
-25,6
+25,7
@@
struct SilcMutexStruct {
#ifdef SILC_THREADS
pthread_mutex_t mutex;
struct SilcMutexStruct {
#ifdef SILC_THREADS
pthread_mutex_t mutex;
+ unsigned int locked : 1;
#else
void *tmp;
#endif /* SILC_THREADS */
#else
void *tmp;
#endif /* SILC_THREADS */
@@
-36,7
+37,6
@@
bool silc_mutex_alloc(SilcMutex *mutex)
*mutex = silc_calloc(1, sizeof(**mutex));
if (*mutex == NULL)
return FALSE;
*mutex = silc_calloc(1, sizeof(**mutex));
if (*mutex == NULL)
return FALSE;
-
pthread_mutex_init(&(*mutex)->mutex, NULL);
#endif /* SILC_THREADS */
return TRUE;
pthread_mutex_init(&(*mutex)->mutex, NULL);
#endif /* SILC_THREADS */
return TRUE;
@@
-55,12
+55,16
@@
void silc_mutex_lock(SilcMutex mutex)
#ifdef SILC_THREADS
if (pthread_mutex_lock(&mutex->mutex))
assert(FALSE);
#ifdef SILC_THREADS
if (pthread_mutex_lock(&mutex->mutex))
assert(FALSE);
+ assert(mutex->locked == 0);
+ mutex->locked = 1;
#endif /* SILC_THREADS */
}
void silc_mutex_unlock(SilcMutex mutex)
{
#ifdef SILC_THREADS
#endif /* SILC_THREADS */
}
void silc_mutex_unlock(SilcMutex mutex)
{
#ifdef SILC_THREADS
+ assert(mutex->locked == 1);
+ mutex->locked = 0;
if (pthread_mutex_unlock(&mutex->mutex))
assert(FALSE);
#endif /* SILC_THREADS */
if (pthread_mutex_unlock(&mutex->mutex))
assert(FALSE);
#endif /* SILC_THREADS */