Using a epoll and aio - Linux

This is a discussion on Using a epoll and aio - Linux ; Hello, i'm using epoll and aio with TCP sockets on a Ubuntu 7.10 AMD64 system. I have one thread which waits for epoll events. The epoll thread informs me when new data is available (EPOLLIN) and i issue an aio ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Using a epoll and aio

  1. Using a epoll and aio

    Hello,

    i'm using epoll and aio with TCP sockets on a Ubuntu 7.10 AMD64 system. I
    have one thread which waits for epoll events. The epoll thread informs me
    when new data is available (EPOLLIN) and i issue an aio read request
    (IO_CMD_PREAD). But under certain circumstances the epoll thread
    continously informs me about new data available to read.
    To my knowledge the submitted read request should eliminate further EPOLLIN
    notifications until new data from the network is ready. Am I wrong? Have
    anyone experienced the same problem?

    Thanks,

    Andreas Roth


  2. Re: Using a epoll and aio

    On Oct 26, 8:04 am, Andreas Roth wrote:

    > i'm using epoll and aio with TCP sockets on a Ubuntu 7.10 AMD64 system. I
    > have one thread which waits for epoll events. The epoll thread informs me
    > when new data is available (EPOLLIN) and i issue an aio read request
    > (IO_CMD_PREAD). But under certain circumstances the epoll thread
    > continously informs me about new data available to read.
    > To my knowledge the submitted read request should eliminate further EPOLLIN
    > notifications until new data from the network is ready. Am I wrong? Have
    > anyone experienced the same problem?


    You are expecting an asynchronous request to have a synchronous
    effect. It does not. An asynchronous request may take effect at some
    unspecified future time, out of synch with your epoll loop.

    Are you sockets set non-blocking or blocking?

    DS


  3. Re: Using a epoll and aio

    David Schwartz wrote:

    > On Oct 26, 8:04 am, Andreas Roth wrote:
    >
    >> i'm using epoll and aio with TCP sockets on a Ubuntu 7.10 AMD64 system. I
    >> have one thread which waits for epoll events. The epoll thread informs me
    >> when new data is available (EPOLLIN) and i issue an aio read request
    >> (IO_CMD_PREAD). But under certain circumstances the epoll thread
    >> continously informs me about new data available to read.
    >> To my knowledge the submitted read request should eliminate further
    >> EPOLLIN notifications until new data from the network is ready. Am I
    >> wrong? Have anyone experienced the same problem?

    >
    > You are expecting an asynchronous request to have a synchronous
    > effect. It does not. An asynchronous request may take effect at some
    > unspecified future time, out of synch with your epoll loop.

    To avoid starting the same receive operation again i need to ignore the
    EPOLLIN notifications. To ignore them is easy, but the epoll loop is still
    active and is spinning. I could remove the socket from the epoll after a
    recv operation has been started, but this is quite expensive and in most
    cases not necessary.
    >
    > Are you sockets set non-blocking or blocking?


    All sockets are non-blocking.
    >
    > DS


    Thanks four your help.
    --
    Andreas Roth


  4. Re: Using a epoll and aio

    On Oct 26, 11:39 pm, Andreas Roth wrote:

    > To avoid starting the same receive operation again i need to ignore the
    > EPOLLIN notifications. To ignore them is easy, but the epoll loop is still
    > active and is spinning. I could remove the socket from the epoll after a
    > recv operation has been started, but this is quite expensive and in most
    > cases not necessary.


    Why not just perform the 'read' synchronously? The socket is non-
    blocking, so the 'read' operation won't block. As soon as you finish
    reading, but before you process any data, allow the 'epoll' thread to
    make forward progress.

    I usually do this with a counter. When 'epoll' returns, as I handle
    each read or write job, I increment a counter. As I complete the
    socket operation (but no other operations needed), I decrement the
    counter. When the counter reaches zero, I can try to discover new
    sockets.

    DS


  5. Re: Using a epoll and aio

    On Sat, 27 Oct 2007 08:39:38 +0200, Andreas Roth wrote:
    > David Schwartz wrote:
    >> On Oct 26, 8:04 am, Andreas Roth wrote:
    >>> i'm using epoll and aio with TCP sockets on a Ubuntu 7.10 AMD64 system. I
    >>> have one thread which waits for epoll events. The epoll thread informs me
    >>> when new data is available (EPOLLIN) and i issue an aio read request

    >> You are expecting an asynchronous request to have a synchronous
    >> effect. It does not. An asynchronous request may take effect at some
    >> unspecified future time, out of synch with your epoll loop.

    > To avoid starting the same receive operation again i need to ignore the
    > EPOLLIN notifications.


    Would EPOLLET (edge triggered) help?

    But I still don't really see the point why you are trying to use
    asynchronous IO at all. BTW, is the Linux aio implementation actually
    asynchronous or does it use a synchronous read request behind the scenes?


    Christof

    --
    http://cmeerw.org sip:cmeerw at cmeerw.org
    mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org

+ Reply to Thread