reliable unbinding of names
Jan Lessner
jan@c-lab.de
Mon, 16 Feb 1998 21:46:16 +0100
Paul
> I have a server which binds each object it creates to the Naming Service as
> the objects are created and then blocks in the boa waiting for requests. I
> have coded the destructors for the object implementations so that they will
> automatically unbind themselves from the name server.
>
> This works fine if I call _dispose for each object instance, but if I type
> CTR-C the server simply exits without calling the destructors, hence the
> objects remain registered.
>
> Is there a "reliable" way of doing what I want. I.e ensuring that when the
> server exits the name server is cleaned up, other than restaring the name
> service between runs or deleting the hierarchy of names on start-up?.
To my opinion there's no chance to garuantee propper cleanup of the
naeming service's registrations. Even if you catch CTRL-C there's still
the risk of your application to crash or the whole machine to be just
switched off. So you can never be sure that your destructors are
actually run.
As the naming service itself doesn't actually communicate with the
registered objects it will never get aware of registered objects
becoming invalid (resp. vanishing). The only solution I could think of
is to let the naming service ping all registered objects before any
application accesses its registration data by running any nameing
service methods. But this would waste plenty of time and increase the
risc of deadlock situations.
On the other way, I don't actually see a need for propper clean up. We
added a general routine in our server which does the object
registration. If registration failes with an AlreadyBound exception, it
fetches the bound object, checks wether this object is still valid
(CORBA::Object:_non_existent() ) and performs a rebound operation in
case it is not. This way it is not required to rely on propper cleanup
making the whole application more robust against worst-case conditions.
Regards
Jan Lessner, C-LAB
--
>>>>> C-LAB @ CeBIT'98: Hall 6, A32, Booth 322