[omniORB] Bug in tcpConnection::Recv and Send functions
Duncan Grisby
duncan at grisby.org
Mon May 11 15:08:41 UTC 2020
On Sat, 2020-05-09 at 18:15 +0200, Serguei Kolos via omniORB-list
wrote:
> I start my CORBA server application
> I start me CORBA client that make a call to the server
> I kill the server
> 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.
> The problem occurs because Ctrl-C signal sets the errno variable to
> EINTR, which masks the socket error
> due to the following code in the tcpSocket::waitRead() function:
> > if (rc > 0 && fds.revents & POLLERR) {
> > rc = RC_SOCKET_ERROR;
> > }
If a signal occurs, like SIGINT in this case, poll() is expected to
return an error with errno equal to EINTR. From "man 7 signal" on
Linux, for example:
The following interfaces are never restarted after being interrupted by
a signal handler, regardless of the use of SA_RESTART; they always fail
with the error EINTR when interrupted by a signal handler:
[...]
* File descriptor multiplexing interfaces: epoll_wait(2),
epoll_pwait(2), poll(2), ppoll(2), select(2), and pselect(2).
So the correct logic if errno=EINTR occurs is to retry the poll() call,
and that is what omniORB's code is trying to do.
> This function returns RC_SOCKET_ERROR and the tcpConnection::Recv
> enters into a crazy loop until the timeout occurs because of the
> following code:
> > tx = tcpSocket::waitRead(pd_socket, t);
> > ...
> > if (tx == RC_SOCKET_ERROR) {
> > if (ERRNO == RC_EINTR) {
> > continue;
> > }
I think the problem here is that the next call to poll() is not
clearing errno. That means that it sees a POLLERR return, and should
notice the connection closure, but instead errno is still set to EINTR.
Does it work if you modify that code with the continue to clear errno
first?
if (tx == RC_SOCKET_ERROR) {
if (ERRNO == RC_EINTR) {
errno = 0;
continue;
}
Duncan.
--
-- Duncan Grisby --
-- duncan at grisby.org --
-- http://www.grisby.org --
More information about the omniORB-list
mailing list