Update of /cvsroot/simplemail/simplemail/gtk
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv32666/gtk
Modified Files:
subthreads.c
Log Message:
Implemented proper failure support for thread_add().
Also lock the mutex before the thread is created.
Index: subthreads.c
===================================================================
RCS file: /cvsroot/simplemail/simplemail/gtk/subthreads.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- subthreads.c 24 Dec 2013 09:24:33 -0000 1.49
+++ subthreads.c 24 Dec 2013 09:24:51 -0000 1.50
@@ -229,17 +229,25 @@
list_insert_tail(&thread_list, &t->node);
g_mutex_unlock(thread_list_mutex);
- if ((g_thread_create(thread_add_entry,&tad,TRUE,NULL)))
+ g_mutex_lock(thread_mutex);
+ if (!g_thread_create(thread_add_entry,&tad,TRUE,NULL))
{
- g_mutex_lock(thread_mutex);
- while (!thread_parent_can_continue)
- g_cond_wait(thread_cond,thread_mutex);
- thread_parent_can_continue = 0;
- g_mutex_unlock(thread_mutex);
- return t;
+ g_mutex_lock(thread_list_mutex);
+ node_remove(&t->node);
+ g_mutex_unlock(thread_list_mutex);
+ free(t);
+ t = NULL;
+ goto bailout;
}
- /* TODO: Remove thread */
- return NULL;
+
+ /* Wait until we are signaled to continue */
+ while (!thread_parent_can_continue)
+ g_cond_wait(thread_cond,thread_mutex);
+ thread_parent_can_continue = 0;
+bailout:
+ g_mutex_unlock(thread_mutex);
+
+ return t;
}
/***************************************************************************************/
|