From cde4e55e47ae031af23746b45981fd0fd3a40cad Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 12 Aug 2011 22:32:14 +0000 Subject: 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/qpid@1157273 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/epoll/EpollPoller.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/epoll/EpollPoller.cpp b/cpp/src/qpid/sys/epoll/EpollPoller.cpp index 9ad05c71a3..dcc9d9181c 100644 --- a/cpp/src/qpid/sys/epoll/EpollPoller.cpp +++ b/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; -- cgit v1.2.1