Skip to content

Commit

Permalink
Merge pull request #382 from CopernicaMarketingSoftware/retry-interrupt
Browse files Browse the repository at this point in the history
retry poll when interrupted by a signal
  • Loading branch information
EmielBruijntjes committed Nov 23, 2020
2 parents 7f40ad2 + e4ec629 commit ad5ecea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/linux_tcp/tcpresolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,17 @@ class TcpResolver : public TcpExtState
fd.events = POLLOUT;
fd.revents = 0;

// perform the poll, with a very long time to allow the event to occur
int ret = poll(&fd, 1, _timeout * 1000);
// the return code
int ret = 0;

// keep looping until we get a 'final' result
do
{
// perform the poll, with a very long time to allow the event to occur
ret = poll(&fd, 1, _timeout * 1000);

// we want to retry if the call was interrupted by a signal
} while (ret == -1 && errno == EINTR);

// log the error for the time being
if (ret == 0) _error = "connection timed out";
Expand Down

0 comments on commit ad5ecea

Please sign in to comment.