From: Sebastian B. <sb...@us...> - 2013-12-24 09:28:55
|
Update of /cvsroot/simplemail/simplemail/gtk In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv725/gtk Modified Files: subthreads.c Log Message: Use recursive mutexes for the semaphores. Index: subthreads.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/gtk/subthreads.c,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- subthreads.c 24 Dec 2013 09:28:36 -0000 1.59 +++ subthreads.c 24 Dec 2013 09:28:53 -0000 1.60 @@ -695,7 +695,7 @@ struct semaphore_s { - GMutex *mutex; + GStaticRecMutex mutex; }; semaphore_t thread_create_semaphore(void) @@ -703,32 +703,27 @@ semaphore_t sem = malloc(sizeof(struct semaphore_s)); if (sem) { - if (!(sem->mutex = g_mutex_new())) - { - free(sem); - return NULL; - } + g_static_rec_mutex_init(&sem->mutex); } return sem; } void thread_dispose_semaphore(semaphore_t sem) { - g_mutex_free(sem->mutex); free(sem); } void thread_lock_semaphore(semaphore_t sem) { - g_mutex_lock(sem->mutex); + g_static_rec_mutex_lock(&sem->mutex); } int thread_attempt_lock_semaphore(semaphore_t sem) { - return g_mutex_trylock(sem->mutex); + return g_static_rec_mutex_trylock(&sem->mutex); } void thread_unlock_semaphore(semaphore_t sem) { - g_mutex_unlock(sem->mutex); + g_static_rec_mutex_unlock(&sem->mutex); } |