Re: graceful mulit-threaded shutdown



Hi,

On Mon, 10 Nov 2003 17:48:03 +0100, Tyler Kohn wrote:
> 
> Thanks, I went ahead and did this and it works great for getting me out of
> the running thread, but I still am getting a seg fault.

BTW I recommend
	LD_PRELOAD=/usr/lib/libefence.so

as otherwise the point of failure may be misleading.


> When it finally
> crashed during shutdown, the backtrace is:
> 
> #0  0x401ce23f in ORBit_POA_setup_root () from /usr/lib/libORBit-2.so.0
> #1  0xbffff690 in ?? ()
> #2  0x401cd219 in ORBit_POA_is_inuse () from /usr/lib/libORBit-2.so.0
> #3  0x40246ee6 in g_hash_table_foreach () from /usr/lib/libglib-2.0.so.0
> #4  0x401cd317 in ORBit_POA_deactivate () from /usr/lib/libORBit-2.so.0
> #5  0x401cd081 in ORBit_POA_is_inuse () from /usr/lib/libORBit-2.so.0
> #6  0x401cfd24 in PortableServer_POA_destroy () from
> /usr/lib/libORBit-2.so.0
> #7  0x401bd03f in CORBA_ORB_shutdown () from /usr/lib/libORBit-2.so.0
> #8  0x401bd0f9 in CORBA_ORB_destroy () from /usr/lib/libORBit-2.so.0
> #9  0x401bbab1 in ORBit_ORB_start_servers () from /usr/lib/libORBit-2.so.0
> #10 0x4202ac92 in exit () from /lib/i686/libc.so.6
> #11 0x420158ff in __libc_start_main () from /lib/i686/libc.so.6
> (gdb)
> 
> the poa doesn't seem to want to shutdown due to remaining refrence.  during
> the lifecycle of my app I create the orb, a server, and a client.  On
> shutdown I clean up the client first:
> 	CORBA_Object_release(client, ev);
> I don't release the orb yet since the server still is around.
> 
> I then call 
> 	g_main_loop_quit(loop);

Beware: I do not use Naming service, I depend on direct IOR references.
Complete sequence I use with clean referencing and shutdown:

	/* Init 'orb' */
	/* libcaptive is single-threaded only, caller must lock it.
	 * If thread A spawned the sandbox while currently doing its own work
	 * and thread B calls the sandbox thread B waits on ORB_run()
	 * while the sandbox waits for the response of thread A ORB. Deadlock.
	 * "orbit-local-non-threaded-orb" requests thread unaware ORB.
	 */
	*orbp=CORBA_ORB_init(&orb_argc,orb_argv,"orbit-local-non-threaded-orb",evp);
	/* Init 'poa' */
	*poap=(PortableServer_POA)CORBA_ORB_resolve_initial_references(*orbp,"RootPOA",evp);
	{
	PortableServer_POAManager poa_mgr;
		poa_mgr=PortableServer_POA__get_the_POAManager(*poap,evp);
		PortableServer_POAManager_activate(poa_mgr,evp);
		CORBA_Object_release((CORBA_Object)poa_mgr,evp);
	}
	/* Init 'Vfs_object' */
	Vfs_object=impl_Captive_Vfs__create(captive_corba_poa,&captive_corba_ev);
	/* Pass IOR to our parent. */
	Vfs_IOR=CORBA_ORB_object_to_string(captive_corba_orb,Vfs_object,&captive_corba_ev);
	printf("ior=%s\n",Vfs_IOR);

	g_main_loop_run(captive_corba_get_loop());

	/* Shutdown 'Vfs' servant */
	Vfs_servant=PortableServer_POA_reference_to_servant(captive_corba_poa,Vfs_object,&captive_corba_ev);
	CORBA_Object_release(Vfs_object,&captive_corba_ev);
	impl_Captive_Vfs__destroy(Vfs_servant,&captive_corba_ev);
	/* Shutdown 'poa' */
	CORBA_Object_release((CORBA_Object)poa,evp);
	/* Shutdown 'orb' */
	CORBA_ORB_destroy(orb,evp);


I am not aware of current inter-thread issues of ORBit-2.7.x+, it is valid for
me to use:
	  CORBA_ORB_init(&orb_argc,orb_argv,"orbit-local-non-threaded-orb",evp);

If you need just to call g_main_loop_quit() from a 'different thread' while no
other ORBit features need to be used by 'different threads' I can recommend it
to simplify it all. Michael Meeks may curse me.


> In my "run" method, after g_main_loop_run (loop) returns I call:
>     CORBA_Object_release(servant, ev);
> if that doesn't raise an exception (it doesn't appear to) and if the orb is
> not null, I call:
>         CORBA_ORB_destroy (orb, ev);

The servant itself remains running as its impl_*__destroy() was not called.
Also POA remains alive.



Regards,
Lace

-- 
Jan Kratochvil; Captive: free r/w NTFS Filesystem; http://www.jankratochvil.net/



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