ORBit2 r2105 - in trunk: . linc2 linc2/src src/orb/GIOP test test/everything test/poa



Author: tml
Date: Mon Dec 15 11:49:45 2008
New Revision: 2105
URL: http://svn.gnome.org/viewvc/ORBit2?rev=2105&view=rev

Log:
2008-12-15  Tor Lillqvist  <tml novell com>

	Bug 547885 - ORBit2 should not call g_thread_init() itself as it
	is usually too late

	* src/orb/GIOP/giop.c (giop_init): Don't assume that link_init()
	managed to actually take threads into use if requested to. See
	linc2/ChangeLog. Check with giop_thread_safe().

	* test/everything/client.c (main)
	* test/everything/server.c (main)
	* test/poa/poatest-basic-shell.c (main)
	* test/test-corbaloc.c (main) 
	* test/test-dynany.c (main)
	* test/test-giop.c (main)
	* test/test-mem.c (main)
	* test/test-performance.c (main)
	* test/timeout-client.c (main)
	* test/timeout-server.c (main): Call g_thread_init(NULL).

	* linc2/src/linc.c (link_init): Don't call g_thread_init()
	here, it's way too late. g_thread_init() must be the first
	GLib function called in a program if it is called at
	all. Instead, if thread support is requested but
	g_thread_init() has not been called, print a warning and
	continue without threads.



Modified:
   trunk/ChangeLog
   trunk/linc2/ChangeLog
   trunk/linc2/src/linc.c
   trunk/src/orb/GIOP/giop.c
   trunk/test/everything/client.c
   trunk/test/everything/server.c
   trunk/test/poa/poatest-basic-shell.c
   trunk/test/test-corbaloc.c
   trunk/test/test-dynany.c
   trunk/test/test-giop.c
   trunk/test/test-mem.c
   trunk/test/test-performance.c
   trunk/test/timeout-client.c
   trunk/test/timeout-server.c

Modified: trunk/linc2/src/linc.c
==============================================================================
--- trunk/linc2/src/linc.c	(original)
+++ trunk/linc2/src/linc.c	Mon Dec 15 11:49:45 2008
@@ -197,7 +197,15 @@
 #endif
 
 	if (thread_safe && !g_thread_supported ())
-		g_thread_init (NULL);
+		g_warning ("g_thread_init() has not been called. "
+			   "ORBit2 would like to use threads, so the application "
+			   "should have called g_thread_init(NULL) before any "
+			   "GLib or GLib-using API. "
+			   "Calling g_thread_init() now here "
+			   "inside the libORBit-2 library is too late, "
+			   "so instead threads won't be used by ORBit2. "
+			   "This might have bad side-effects. "
+			   "Fix the application!");
 
 	link_is_thread_safe = (thread_safe && g_thread_supported());
 

Modified: trunk/src/orb/GIOP/giop.c
==============================================================================
--- trunk/src/orb/GIOP/giop.c	(original)
+++ trunk/src/orb/GIOP/giop.c	Mon Dec 15 11:49:45 2008
@@ -534,7 +534,7 @@
 {
 	link_init (thread_safe);
 
-	if (thread_safe) {
+	if (giop_thread_safe ()) {
 		GIOPThread *tdata;
 
 		/* We need a destructor to clean up if giopthreads are used

Modified: trunk/test/everything/client.c
==============================================================================
--- trunk/test/everything/client.c	(original)
+++ trunk/test/everything/client.c	Mon Dec 15 11:49:45 2008
@@ -37,7 +37,7 @@
 #ifdef TIMING_RUN
 #  define d_print(a)
 #else
-#  define d_print(a) if (!thread_tests) g_print(a)
+#  define d_print(a) if (!thread_tests && a != NULL) g_print(a)
 #endif
 
 extern CORBA_ORB global_orb;
@@ -2556,6 +2556,8 @@
 	char              *orb_name;
 	int                i;
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (ev);
 
 /* FIXME - make this work nicely sometime.

Modified: trunk/test/everything/server.c
==============================================================================
--- trunk/test/everything/server.c	(original)
+++ trunk/test/everything/server.c	Mon Dec 15 11:49:45 2008
@@ -528,6 +528,8 @@
 
 	free (malloc (8)); /* -lefence */
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init(&real_ev);
 
 	for (i = 0; i < argc; i++) {

Modified: trunk/test/poa/poatest-basic-shell.c
==============================================================================
--- trunk/test/poa/poatest-basic-shell.c	(original)
+++ trunk/test/poa/poatest-basic-shell.c	Mon Dec 15 11:49:45 2008
@@ -36,6 +36,8 @@
 	PortableServer_POAManager poa_mgr;
 	poatest                   poatest_obj;
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (&ev);
 
 	orb = CORBA_ORB_init (&argc, argv, "", &ev);

Modified: trunk/test/test-corbaloc.c
==============================================================================
--- trunk/test/test-corbaloc.c	(original)
+++ trunk/test/test-corbaloc.c	Mon Dec 15 11:49:45 2008
@@ -187,6 +187,8 @@
 	CORBA_Environment ev;
 	CORBA_ORB orb;
 	
+	g_thread_init (NULL);
+
 	CORBA_exception_init(&ev);
 	orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
 

Modified: trunk/test/test-dynany.c
==============================================================================
--- trunk/test/test-dynany.c	(original)
+++ trunk/test/test-dynany.c	Mon Dec 15 11:49:45 2008
@@ -571,6 +571,8 @@
 
 	free (malloc (8));
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (&ev);
 	orb = CORBA_ORB_init (NULL, NULL, "orbit-local-orb", &ev);
   

Modified: trunk/test/test-giop.c
==============================================================================
--- trunk/test/test-giop.c	(original)
+++ trunk/test/test-giop.c	Mon Dec 15 11:49:45 2008
@@ -331,6 +331,8 @@
 	CORBA_ORB orb;
 	CORBA_Environment ev;
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (&ev);
 
 	orb = CORBA_ORB_init (&argc, argv, "orbit-local-orb", &ev);

Modified: trunk/test/test-mem.c
==============================================================================
--- trunk/test/test-mem.c	(original)
+++ trunk/test/test-mem.c	Mon Dec 15 11:49:45 2008
@@ -258,6 +258,7 @@
 main(int argc, char *argv[]) {
 	/* ORBit2-2.7.6 leaks on shutdown with about 700KB */
 	/* LEAK_DETECT_WITH_TOLERANCE (1, main_func (argc,argv), 20); */
+	g_thread_init (NULL);
 	main_func (argc, argv);
 	exit (0);
 }

Modified: trunk/test/test-performance.c
==============================================================================
--- trunk/test/test-performance.c	(original)
+++ trunk/test/test-performance.c	Mon Dec 15 11:49:45 2008
@@ -175,6 +175,8 @@
 
 	free (malloc (8));
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (&ev);
 
 	timer = g_timer_new ();

Modified: trunk/test/timeout-client.c
==============================================================================
--- trunk/test/timeout-client.c	(original)
+++ trunk/test/timeout-client.c	Mon Dec 15 11:49:45 2008
@@ -154,6 +154,8 @@
 	CORBA_ORB orb;
 	int retv = EXIT_FAILURE;
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (&ev);
 
 	/* create timeout orb */

Modified: trunk/test/timeout-server.c
==============================================================================
--- trunk/test/timeout-server.c	(original)
+++ trunk/test/timeout-server.c	Mon Dec 15 11:49:45 2008
@@ -92,6 +92,8 @@
 	signal(SIGINT, exit);
 	signal(SIGTERM, exit);
 
+	g_thread_init (NULL);
+
 	CORBA_exception_init (&ev);
 
 	/* create IPv4 orb */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]