[uim-commit] r1321 - trunk/uim

tkng at freedesktop.org tkng at freedesktop.org
Thu Aug 25 15:47:21 PDT 2005


Author: tkng
Date: 2005-08-25 15:47:18 -0700 (Thu, 25 Aug 2005)
New Revision: 1321

Modified:
   trunk/uim/uim.c
Log:
* uim/uim.c:
 -(initing_or_quiting): New mutex to lock uim_init and uim_quit.
 -(uim_init, uim_quit): Locks added to be thread safe function.


Modified: trunk/uim/uim.c
===================================================================
--- trunk/uim/uim.c	2005-08-25 22:42:11 UTC (rev 1320)
+++ trunk/uim/uim.c	2005-08-25 22:47:18 UTC (rev 1321)
@@ -60,6 +60,9 @@
 static int uim_initialized;
 static int uim_quiting;
 
+/* Definition of mutex */
+UIM_NEW_MUTEX_STATIC(initing_or_quiting);
+
 void
 uim_set_preedit_cb(uim_context uc,
 		   void (*clear_cb)(void *ptr),
@@ -607,7 +610,7 @@
 }
 
 static void
-uim_init_scm()
+uim_init_scm(void)
 {
   int i;
   char *scm_files = NULL;
@@ -666,7 +669,10 @@
 int
 uim_init(void)
 {
+  UIM_LOCK_MUTEX(initing_or_quiting);
+
   if (uim_initialized) {
+    UIM_UNLOCK_MUTEX(initing_or_quiting);
     return 0;
   }
   uim_last_client_encoding = NULL;
@@ -674,6 +680,8 @@
   uim_nr_im = 0;
   uim_init_scm();
   uim_initialized = 1;
+
+  UIM_UNLOCK_MUTEX(initing_or_quiting);
   return 0;
 }
 
@@ -682,7 +690,10 @@
 {
   int i;
 
+  UIM_LOCK_MUTEX(initing_or_quiting);
+  
   if (!uim_initialized || uim_quiting) {
+    UIM_UNLOCK_MUTEX(initing_or_quiting);
     return;
   }
   /* Some multithreaded applications calls uim_quit bursty. */
@@ -701,4 +712,5 @@
   uim_last_client_encoding = NULL;
   uim_initialized = 0;
   uim_quiting = 0;
+  UIM_UNLOCK_MUTEX(initing_or_quiting);
 }



More information about the uim-commit mailing list