Skip to main content

How can idle connections be forced to close, without depending on whether there are client side object references bound to a connection?

  • February 16, 2013
  • 0 replies
  • 0 views

Problem:

  • Product Name: VisiBroker for C
  • Product Version: 5.x
  • Product Component: Connection Management
  • Platform/OS Version: All

How can idle connections be forced to close, without depending on whether there are client side object references bound to a connection?

Resolution:

To ensure the forcing of Client side idle connections to cleanup, a new api is available in vutil.h


static CORBA::Long release_idle_connections(CORBA::ORB_ptr orb, CORBA::Long howmany);


VISUtil::release_idle_connections() is a synchronous call, i.e. it releases the idle connections before returning. First, the cached connections are cleaned up, followed by the non-cached connections. Most of the time taken is used to iterate through the connections and to close them. Broken connections (when the peer has closed the connections) are checked performing a non-blocking read on the connection. If an error occurs the connection is then closed and released.
The parameter "howmany" allows the Client side application to specify the number of connections that are not actively sending data to be closed.

The following code snippet demonstrates how to call release_idle_connections right before we make a method invocation on the callback object.
#include "vutil.h"

..........

// call release_idle_connections right before we make a method invocation
VISUtil::release_idle_connections(_orb, 1);

// make a oneway method invocation on the callback object
obj->oneway_callback();

.........

 

For VisiBroker on Java, please refer to the article [[knowledge_base: VBJ - How to close the client connection programmatically]].


#Security
#VisiBroker