projects
/
crypto.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clear locked flag before unlocking mutex, not after.
[crypto.git]
/
lib
/
silcutil
/
unix
/
silcunixthread.c
diff --git
a/lib/silcutil/unix/silcunixthread.c
b/lib/silcutil/unix/silcunixthread.c
index 6e85dd743981702723a8f34e7a006d3eb8ef73d4..2415a380e31eb3bb21509ff4be74b9c58ce07d2b 100644
(file)
--- a/
lib/silcutil/unix/silcunixthread.c
+++ b/
lib/silcutil/unix/silcunixthread.c
@@
-97,6
+97,14
@@
SilcBool silc_thread_wait(SilcThread thread, void **exit_value)
#endif
}
#endif
}
+void silc_thread_yield(void)
+{
+#ifdef SILC_THREADS
+#ifdef HAVE_SCHED_YIELD
+ sched_yield();
+#endif /* HAVE_SCHED_YIELD */
+#endif /* SILC_THREADS */
+}
/***************************** SILC Mutex API *******************************/
/***************************** SILC Mutex API *******************************/
@@
-136,8
+144,7
@@
void silc_mutex_lock(SilcMutex mutex)
{
#ifdef SILC_THREADS
if (mutex) {
{
#ifdef SILC_THREADS
if (mutex) {
- if (pthread_mutex_lock(&mutex->mutex))
- SILC_ASSERT(FALSE);
+ SILC_VERIFY(pthread_mutex_lock(&mutex->mutex) == 0);
mutex->locked = TRUE;
}
#endif /* SILC_THREADS */
mutex->locked = TRUE;
}
#endif /* SILC_THREADS */
@@
-147,9
+154,8
@@
void silc_mutex_unlock(SilcMutex mutex)
{
#ifdef SILC_THREADS
if (mutex) {
{
#ifdef SILC_THREADS
if (mutex) {
- if (pthread_mutex_unlock(&mutex->mutex))
- SILC_ASSERT(FALSE);
mutex->locked = FALSE;
mutex->locked = FALSE;
+ SILC_VERIFY(pthread_mutex_unlock(&mutex->mutex) == 0);
}
#endif /* SILC_THREADS */
}
}
#endif /* SILC_THREADS */
}
@@
-158,7
+164,7
@@
void silc_mutex_assert_locked(SilcMutex mutex)
{
#ifdef SILC_THREADS
if (mutex)
{
#ifdef SILC_THREADS
if (mutex)
- SILC_
ASSERT
(mutex->locked);
+ SILC_
VERIFY
(mutex->locked);
#endif /* SILC_THREADS */
}
#endif /* SILC_THREADS */
}
@@
-208,7
+214,7
@@
void silc_rwlock_wrlock(SilcRwLock rwlock)
{
#ifdef SILC_THREADS
if (rwlock)
{
#ifdef SILC_THREADS
if (rwlock)
-
pthread_rwlock_wrlock(&rwlock->rwlock
);
+
SILC_VERIFY(pthread_rwlock_wrlock(&rwlock->rwlock) == 0
);
#endif /* SILC_THREADS */
}
#endif /* SILC_THREADS */
}
@@
-216,7
+222,7
@@
void silc_rwlock_unlock(SilcRwLock rwlock)
{
#ifdef SILC_THREADS
if (rwlock)
{
#ifdef SILC_THREADS
if (rwlock)
-
pthread_rwlock_unlock(&rwlock->rwlock
);
+
SILC_VERIFY(pthread_rwlock_unlock(&rwlock->rwlock) == 0
);
#endif /* SILC_THREADS */
}
#endif /* SILC_THREADS */
}