Skip to content

Commit

Permalink
HPCC-19323 Poll() to handle EINTR consistently
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Kelly <mark.kelly@lexisnexisrisk.com>
  • Loading branch information
mckellyln committed May 4, 2018
1 parent cd1cbe4 commit 10808ed
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions system/jlib/jsocket.cpp
Expand Up @@ -1293,7 +1293,12 @@ bool CSocket::connect_timeout( unsigned timeout, bool noexception)
else if (rc<0)
{
err = ERRNO();
LOGERR2(err,2,"::select/poll");
if (err != JSE_INTR)
{
LOGERR2(err,2,"::select/poll");
errclose();
break;
}
}
}
if (err==0)
Expand Down Expand Up @@ -1427,8 +1432,11 @@ void CSocket::connect_wait(unsigned timems)
if (rc<0)
{
err = ERRNO();
LOGERR2(err,2,"::select/poll");
break;
if (err != JSE_INTR)
{
LOGERR2(err,2,"::select/poll");
break;
}
}
if (!timeoutms)
{
Expand Down Expand Up @@ -1569,7 +1577,7 @@ int CSocket::logPollError(unsigned revents, const char *rwstr)
else if (revents & POLLNVAL)
{
StringBuffer errStr;
errStr.appendf("%s POLLINVAL", rwstr);
errStr.appendf("%s POLLNVAL", rwstr);
LOGERR2(999,3,errStr.str());
}
else
Expand Down Expand Up @@ -3965,12 +3973,18 @@ class CSocketBaseThread: public Thread
return true;
else if (rc>0)
{
if ( !(fds[0].revents & POLLNVAL) ) // TODO: MCK - also check POLLERR here ?
if ( !(fds[0].revents & POLLNVAL) ) // MCK - skip POLLERR here
{
// PROGLOG("CSocketBaseThread: poll handle %d selected(2) %d",sock,rc);
return true;
}
}
else
{
int err = ERRNO();
if (err == JSE_INTR)
return true; // assume ok until next time called
}
StringBuffer sockstr;
const char *tracename = sockstr.append((unsigned)sock).str();
LOGERR2(ERRNO(),3,"CSocketBaseThread poll handle");
Expand Down Expand Up @@ -6442,7 +6456,15 @@ class CSocketConnectWait: implements ISocketConnectWait, public CInterface
else
{ // select/poll failed
err = ERRNO();
LOGERR(err,2,"CSocketConnectWait ::select/poll");
if (err != JSE_INTR)
{
LOGERR(err,2,"CSocketConnectWait ::select/poll");
sock->errclose();
isopen = false;
if (!oneshot)
connectimedout = true; // to force same behavior as before
break;
}
}
}
if (err==0)
Expand Down

0 comments on commit 10808ed

Please sign in to comment.