Re: POLLRDONCE optimisation for epoll users (was: epoll and half closed TCP connections)

From: Davide Libenzi (davidel@xmailserver.org)
Date: Sun Jul 13 2003 - 21:37:28 EST


On Mon, 14 Jul 2003, Jamie Lokier wrote:

> Jamie Lokier wrote:
> > Anyway, there is a correct answer and I have made the patch so wait
> > for next mail... :)
>
> The patch is included below. Note, it compiles and has been carefully
> scrutinised by a team of master coders, but never actually run. Eric,
> you may want to try it out :)
>
> The difference between this and POLLRDHUP is polarity, generality and
> correctness :)
>
> Eric, change the polarity of your test from
>
> if (events & POLLRDHUP)
> goto read_again;
>
> to
>
> if (!(events & POLLRDONCE))
> goto read_again;
>
> and it should (fingers crossed) work well.

Ouch, I definitely liked more the POLLHUP thing. It is not linked to epoll
at all. Ok, suppose that our super-fast app choses Edge Triggered epoll
and also, aiming at topp speeds, using the smart read(2) trick :

void my_process_read(my_data *d, unsigned int events) {
        int n, s;

        do {
                s = d->buffer_size - d->in_buffer;
                if ((n = read(d->fd, d->buffer + d->in_buffer, s)) > 0) {
                        process_partial_buffer(d, s);
                        d->in_buffer += s;
                }
        } while (n == s);
        if (s == -1 && errno != EAGAIN) {
                handle_read_error(d);
                return;
        }
        if (events & EPOLLRDHUP) {
                d->flags |= HANGUP;
                schedule_removal(d);
        }
}

Where this will break by using a POLLRDHUP ?

- Davide

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 15 2003 - 22:00:49 EST