Re: [Patch][RFC] epoll and half closed TCP connections

Jamie Lokier (jamie@shareable.org)
Sat, 12 Jul 2003 20:44:32 +0100


Eric Varsanyi wrote:
> - epoll_wait() returns a single EPOLLIN event on the FD representing
> both the 1/2 shutdown state and data available

Correct.

> At this point there is no way the app can tell if there is a half closed
> connection so it may issue a close() back to the client after writing
> results. Normally the server would distinguish these events by assuming
> EOF if it got a read ready indication and the first read returned 0 bytes,
> or would issue read calls until less data was returned than was asked for.
>
> In a level triggered world this all just works because the read ready
> indication is driven back to the app as long as the socket state is half
> closed. The event driven epoll mechanism folds these two indications
> together and thus loses one 'edge'.

Well then, use epoll's level-triggered mode. It's quite easy - it's
the default now. :)

If there's an EOF condition pending after you called read(), and then
you call epoll_wait(), you _should_ see another EPOLLIN condition
immediately.

If you aren't seeing epoll_wait() return with EPOLLIN when there's an
EOF pending, *and* you haven't set EPOLLET in the event flags, that's
a bug in epoll. Is that what you're seeing?

-- Jamie
-
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/