[omniORB] Reduce timeout delay?

Sai-Lai Lo S.Lo@orl.co.uk
21 Oct 1998 15:30:51 +0100


>>>>> David Morgenlender writes:

> Using omniORB 2.5, if my CORBA client attempts to invoke the CORBA
> server, when it is not available, there's a long delay before an
> exception is returned.  Is there anyway to reduce this delay?

The delay is the default tcp connect timeout of your platform. I suppose
you are talking about the case when the server is actually switched off. In
this case the timeout could run into tens of seconds depending on how many
retries your tcp stack has been configured to do.

If you prefer, you can change the connect code (tcpSocketMTfactory.cc) in
the ORB to do a timeout.  e.g. This code fragment is in use in
2.6.0. Solaris has a habit of blocking for minutes by default when the
remote machine is switched off.

#if defined(__sunos__) && defined(__sparc__) && __OSVERSION__ >= 5
  // Use non-blocking connect.
  int fl = O_NONBLOCK;
  if (fcntl(sock,F_SETFL,fl) < RC_SOCKET_ERROR) {
    CLOSESOCKET(sock);
    return RC_INVALID_SOCKET;
  }
  if (connect(sock,(struct sockaddr *)&raddr,
	      sizeof(struct sockaddr_in)) == RC_SOCKET_ERROR) 
  {
    if (errno != EINPROGRESS) {
      CLOSESOCKET(sock);
      return RC_INVALID_SOCKET;
    }
    fd_set wrfds;
    FD_ZERO(&wrfds);
    FD_SET(sock,&wrfds);
    struct timeval t = { 30,0 };
    int rc;
    if ((rc = select(sock+1,0,&wrfds,0,&t)) <= 0) {
      // Timeout, do not bother trying again.
      CLOSESOCKET(sock);
      return RC_INVALID_SOCKET;
    }
  }
  // Set the socket back to blocking
  fl = 0;
  if (fcntl(sock,F_SETFL,fl) == RC_SOCKET_ERROR) {
    CLOSESOCKET(sock);
    return RC_INVALID_SOCKET;
  }

#else
  if (connect(sock,(struct sockaddr *)&raddr,
	      sizeof(struct sockaddr_in)) == RC_SOCKET_ERROR) 
  {
    CLOSESOCKET(sock);
    return RC_INVALID_SOCKET;
  }
#endif



Sai-Lai

-- 
Dr. Sai-Lai Lo                          |       Research Scientist
                                        |
E-mail:         S.Lo@orl.co.uk          |       Olivetti & Oracle Research Lab
                                        |       24a Trumpington Street
Tel:            +44 223 343000          |       Cambridge CB2 1QA
Fax:            +44 223 313542          |       ENGLAND