<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Hello<br>
<br>
I have found a bug in the TCP layer of omniORB 4.2.3 but I'm not
sure what's the best way of fixing it.<br>
The issue appears under the following conditions:<br>
<ul>
<li>I start my CORBA server application</li>
<li>I start me CORBA client that make a call to the server</li>
<li>I kill the server</li>
<li>I stop the client with Ctrl-C (that is important!). In this
case when the client tries to make another call to the server it
hangs until the omniORB timeout expires.</li>
</ul>
The problem occurs because Ctrl-C signal sets the <b>errno</b>
variable to <b>EINTR</b>, which masks the socket error<br>
due to the following code in the tcpSocket::waitRead() function:<br>
<blockquote><tt>if (rc > 0 && fds.revents & POLLERR)
{</tt><tt><br>
</tt><tt> rc = RC_SOCKET_ERROR;</tt><tt><br>
</tt><tt>}</tt><tt><br>
</tt></blockquote>
This function returns RC_SOCKET_ERROR and the tcpConnection::Recv
enters into a crazy loop until<br>
the timeout occurs because of the following code:<br>
<blockquote><tt>tx = tcpSocket::waitRead(pd_socket, t);</tt><tt><br>
</tt><tt>...</tt><tt><br>
</tt><tt>if (<b>tx == RC_SOCKET_ERROR</b>) {</tt><tt><br>
</tt><tt> if (<b>ERRNO == RC_EINTR</b>) {</tt><tt><br>
</tt><tt> <b>continue</b>;</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> else {</tt><tt><br>
</tt><tt> return -1;</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt>}</tt><br>
</blockquote>
The same issue is present in the tcpConnection::Send function.<br>
As a workaround I have added a line that sets ERRNO to zero if
POLLERR event is detected, but I'm wondering<br>
if that could have undesired consequences in other situations.<br>
<tt><br>
</tt><tt> if (rc > 0 && fds.revents & POLLERR) {</tt><tt><br>
</tt><tt>
rc = RC_SOCKET_ERROR;</tt><tt><br>
</tt><tt>
ERRNO = 0;</tt><tt><br>
</tt><tt>
}</tt><br>
<br>
I would appreciate if someone suggests a proper fix for the issue.<br>
<br>
Cheers,<br>
Serguei<br>
</body>
</html>