On Mon, Jan 25, 2010 at 6:54 PM, Steve Huston <[email protected]> wrote:
> alwaysReadableFd is for a pipe - is there a chance you've closed it?

I think there is.  It looks like the static scope of alwaysReadable
and alwaysReadableFd cause them to get initialized before main().
When my daemon class closes open file descriptors while fork()ing they
get closed.  I still have to figure out how to resolve the conflict.

There is, however, still a bug in the code I originally cited:

    PollerPrivate() :
        epollFd(::epoll_create(DefaultFds)),
        isShutdown(false) {
        QPID_POSIX_CHECK(epollFd);
        ::sigemptyset(&sigMask);
        // Add always readable fd into our set (but not listening to it yet)
        ::epoll_event epe;
        epe.events = 0;
        epe.data.u64 = 0;
        QPID_POSIX_CHECK(::epoll_ctl(epollFd, EPOLL_CTL_ADD,
alwaysReadableFd, &epe));
    }

If an exception is thrown by the second QPID_POSIX_CHECK then the file
descriptor allocated by epollFd(::epoll_create(DefaultFds)) is left
dangling.  A ::close(epollFd) would be needed in the catch() block to
free it.  There are a number of functions with a similar design in
EpollPoller.cpp that might be similarly affected.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to