[omniORB] EAGAIN

Sai-Lai Lo S.Lo@orl.co.uk
17 Jun 1998 23:12:12 +0100


It looks to me the socket has indeed been left in non-blocking mode. Your
patch just make the thread busy polling for a reply. 

Looking at the trace and the code, the socket has not been set back to
blocking after connect. (There should be a fcntl after connect in the
trace.)

The following is a  patch (a '}' has been misplaced) that should fix
the bug. This bug only affects snapshot_980410 and only on Solaris.

tcpSocketMTfactory.cc:

line 794:

#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


Sai-Lai


"Rick H. Wesson" <wessorh@ar.com> writes:

> atached is a partial truss of "nameclt list"
> if the change had not been made the client would have shut down the
> socket and thrwn a CORBA::COM_FAILURE because the errorcode would not
> have been 0, adding the code for EAGAIN, allows the socket to be
> re-checked for some data, i doubt it is that effeciant but it makes
> the code runnable.
> 
> -rick
> 
> sigprocmask(SIG_UNBLOCK, 0xEF546BB8, 0x00000000) = 0
> brk(0x000E1568)                                 = 0
> brk(0x000E3568)                                 = 0
> brk(0x000E3568)                                 = 0
> brk(0x000E5568)                                 = 0
> so_socket(2, 2, 0, "", 1)                       = 5
> fstat64(5, 0xEFFFE698)                          = 0
> getsockopt(5, 65535, 8192, 0xEFFFE79C, 0xEFFFE798) = 0
> setsockopt(5, 65535, 8192, 0xEFFFE79C, 4)       = 0
> fcntl(5, F_SETFL, 0x00000080)                   = 0
> connect(5, 0xEFFFE8C0, 16)                      = 0
> send(5, " G I O P01\0\003\0\0\014".., 32, 0)    = 32
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, " G I O P01\0\004\0\0\0\b".., 8200, 0)  = 20
> send(5, " G I O P01\0\0\0\0\0\0 8".., 68, 0)    = 68
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, " G I O P01\0\001\0\0\08C".., 8200, 0)  = 152
> (write(2, " (", 1)                              = 1
> foowrite(2, " f o o", 3)                                = 3
> ,write(2, " ,", 1)                              = 1
> barwrite(2, " b a r", 3)                                = 3
> ) binding type write(2, " )   b i n d i n g   t y".., 15)       = 15
> ncontextwrite(2, " n c o n t e x t", 8)                 = 8
> 
> write(2, "\n", 1)                               = 1
> send(5, " G I O P01\0\003\0\0\014".., 32, 0)    = 32
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, " G I O P01\0\004\0\0\0\b".., 8200, 0)  = 20
> send(5, " G I O P01\0\0\0\0\0\0 8".., 68, 0)    = 68
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, 0x000E32B8, 8200, 0)                    Err#11 EAGAIN
> recv(5, " G I O P01\0\001\0\0\014".., 8200, 0)  = 32
> send(5, " G I O P01\0\0\0\0\0\0 3".., 63, 0)    = 63
> recv(5, " G I O P01\0\001\0\0\0\f".., 8200, 0)  = 24
> llseek(0, 0, SEEK_CUR)                          = 962942
> _exit(0)
> 

-- 
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