No subject

Gregory Haik <ghaik@ens-lyon.fr> ghaik@ens-lyon.fr
Mon, 5 Mar 2001 18:22:38 +0100 (CET)


Hi all,


I'm implementing some sort of "component configurator pattern", taken from
the excellent book "Pattern-oriented software architecture 2", Douglas
Schmidt.

This basically means that I have a server process wich only contains a
Generic Factory, which is capable of loading a dll and instanciating the
concrete component class contained in this dll. This way, the server
process is completely independant from any implementation class.

The generic factory is a CORBA object having 2 methods :

Object load_impl(in interface_name, in implementation name);
void remove_impl(in Object);

load_impl works, so let's speak about remove_impl :

this operation first looks up the dll handle that has been stored in the
load_impl operation some how (this part is tested). Then it calls a
destroy() operation on the object to be removed. The destroy() operation,
for now, deactivates the object - poa->deactivate_object(id) - and then
performs a this->_remove_ref(), 'this' referring to the servant.

By putting a cout << in the servant destructor, I can see that the
destructor is cleanly being called consequently. Fine. And as far as I can
see, there is no other pointer to the dll code or data structure. But
apparently I don't see far enough : in the
GenFact::remove_impl() operation, after having cleanly destroyed the
object, I perform the dlclose(). And then it segfaults...

A segfault consecutive to a dlclose() looks like there's still a pointer
referring to some code or data structure in the closed dll. Fine. But
that's not in my code (it's simple enough to garantee it). So it's
probably somewhere in omniORB - not that there's a bug, but I'm sure I'm
not using it correctly. 

So basically the question is : in your opinion, when should I perform the
dlclose() ? Is there a thread I should get synchronized with before
destroying the servant code/data ?

Nota : I've tested to isolate the dlclose() in a new GenFact operation to be
called remotely by the client process just after the remove_impl(). And
then it works... 


Any kind of help, idea, ... will be greatly appreciated.