[omniORB] Client crash notification & Smart Proxies

Stefan Seefeld seefelds@MAGELLAN.UMontreal.CA
Wed, 20 Dec 2000 14:25:21 -0500


> JohnSwanStone wrote:

> a) How do you create smart proxies in omniORB.  The only info I've found refers to a section 
> in the user's manual which doesn't have that information anymore (Section 8.2).

you should use some form of distributed ref counting, i.e. derive your servants from an

interface RefCountBase
{
  void increment();
  void decrement();
};

Of course, you need to call these methods explicitely. There is no portable way to add that
to proxy classes. However, what I did to get a similar effect, is to write a smart pointer
template, something like this:

template <typename Interface>
class RefCount_var
{
public:
  RefCount_var(typename Interface::_type_ptr i) : _i(i) {}
 ~RefCount_var()
    { 
      if (!CORBA::is_nil(_i))
        try { _i->decrement();}
        catch (...) {}
    }
//...
}

which you can use like smart proxies:

RefCount_var<SomeObject> object = ...; // assumes ownership like 'normal' vars...

> b) How can I ask omniORB to notify me when a client crashes ... I would also need a client
> identifier so I could look up the and release the resources that client was using.

Again, a solution we use:
For each client there is a pair of ServerContext/ClientContext which serves as a 'session'
pair, responsible for authentication as well as other housekeeping stuff. The ServerContext
lives in the server, the ClientContext in the client. A special thread pings all existing
ClientContexts, and as soon as one times out (well, whatever policy you want), all the
resources the server allocated on behalf of the client are freed. In our case we use client
specific POAs, so all we need is destroy the POAs belonging to a client. With the
PortableServer::RefCountBase mixed into the inheritance for all servants, this deletes all 
servants as well.

Regards,	Stefan
_______________________________________________________              
              
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca

_______________________________________________________

      ...ich hab' noch einen Koffer in Berlin...