summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2011-08-12 22:32:14 +0000
committerAndrew Stitcher <astitcher@apache.org>2011-08-12 22:32:14 +0000
commit1145091da97833195dba7d63a06cec3f0fa12d12 (patch)
tree77f8327a365d71b8d7db69d5097970d58d258017
parentbd46aa4383ca0a04563c80dc527cf005a2a335ad (diff)
downloadqpid-python-1145091da97833195dba7d63a06cec3f0fa12d12.tar.gz
QPID-3405: Slightly hacky way to get reconnect to work
- If we fail to reset the epoll settings of a file handle when going round the poll loop and it's because the handle is not in the epoll set then just try to add it into the epoll set. This gets round the case where connect closes a socket fd (implicitly taking out of all epoll sets) and then tries to connect again. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1157273 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/sys/epoll/EpollPoller.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/qpid/cpp/src/qpid/sys/epoll/EpollPoller.cpp b/qpid/cpp/src/qpid/sys/epoll/EpollPoller.cpp
index 9ad05c71a3..dcc9d9181c 100644
--- a/qpid/cpp/src/qpid/sys/epoll/EpollPoller.cpp
+++ b/qpid/cpp/src/qpid/sys/epoll/EpollPoller.cpp
@@ -384,7 +384,12 @@ void PollerPrivate::resetMode(PollerHandlePrivate& eh) {
epe.data.u64 = 0; // Keep valgrind happy
epe.data.ptr = &eh;
- QPID_POSIX_CHECK(::epoll_ctl(epollFd, EPOLL_CTL_MOD, eh.fd(), &epe));
+ int rc = ::epoll_ctl(epollFd, EPOLL_CTL_MOD, eh.fd(), &epe);
+ // If something has closed the fd in the meantime try adding it back
+ if (rc ==-1 && errno == ENOENT) {
+ rc = ::epoll_ctl(epollFd, EPOLL_CTL_ADD, eh.fd(), &epe);
+ }
+ QPID_POSIX_CHECK(rc);
eh.setActive();
return;