linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: "David S. Miller" <davem@redhat.com>,
	Eric Varsanyi <e0206@foo21.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	kuznet@ms2.inr.ac.ru
Subject: Re: POLLRDONCE optimisation for epoll users (was: epoll and half closed TCP connections)
Date: Mon, 14 Jul 2003 06:51:22 +0100	[thread overview]
Message-ID: <20030714055122.GA24031@mail.jlokier.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.55.0307132044350.15022@bigblue.dev.mcafeelabs.com>

Oh!  I realised why we're mis-communicating.

I started in the assumption that you're using POLLRDHUP to trigger a
second read, but you're using it in a different way (makes sense given
the name!)

You're assuming that a short read is always the last one with data,
that's the read() trick, and detecting EOF is really a wholly separate
problem.

Ah..

First let's get the misc bits out of the way.

Davide Libenzi wrote:
> > (d) SO_RCVLOWAT < s
> 
> This does not apply with non-blocking fds.

Look at the line "if (copied >= target)" in tcp_recvmsg.

> > (e) there is urgent data with OOBINLINE (I think)
> 
> You obviously need an EPOLLPRI check in your read handling routine if you
> app is expecting urgent data.

Normal behaviour is for urgent data to be discarded, I believe.  Now
if someone sends it to you, you'll end up with the socket stalling
with pending data in the buffers.  Not saying whether you care, it's
just a difference of behaviour to be noted and a potential DOS
(filling socket buffers which app doesn't know to empty).

Now on to the important stuff.

> On Mon, 14 Jul 2003, Jamie Lokier wrote:
> 
> > (a) fd isn't a socket
> > (b) fd isn't a TCP socket
> 
> Jamie, libraries, like for example libevent, are completely generic indeed.
> They fetch events and they call the associated callback. You obviously
> know inside your callback which kind of fd you working on.

I disagree - inside a stream parser callback (e.g. XML transcoder) I
prefer to _not_ know the difference between pipe, file, tty and socket
that I am reading.

> So you use the reading function that best fit the fd type. Obviously
> the read(2) trick only works for stream type fds.

Stream fds provided you don't hit the unusual cases.

Point taken.  Now I'm saying there's an interface which is no more or
less complicated, but _doesn't_ require you to treat different kinds
of fds differently.  So I can write code which uses the read() trick
universally without having to pass that extra parameter,
EOF_SETS_RDHUP, to the event callback :)

> > (c) kernel version <= 2.5.75
> 
> Obviously, POLLRDHUP is not yet inside the kernel :)

Quite.  When you write an app that uses it and the read(2) trick
you'll see the bug which Eric brought up :)

I'm saying there's a way to write an app which can use the read(2)
trick, yet which does _not_ hang on older kernels.  Hence is robust.

My overall philosophy on this:

    The less object A needs to know about object B, the better, right?

Right? :)

-- Jamie

  reply	other threads:[~2003-07-14  5:37 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-12 18:16 [Patch][RFC] epoll and half closed TCP connections Eric Varsanyi
2003-07-12 19:44 ` Jamie Lokier
2003-07-12 20:51   ` Eric Varsanyi
2003-07-12 20:48     ` Davide Libenzi
2003-07-12 21:19       ` Eric Varsanyi
2003-07-12 21:20         ` Davide Libenzi
2003-07-12 21:41         ` Davide Libenzi
2003-07-12 23:11           ` Eric Varsanyi
2003-07-12 23:55             ` Davide Libenzi
2003-07-13  1:05               ` Eric Varsanyi
2003-07-13 20:32       ` David Schwartz
2003-07-13 21:10         ` Jamie Lokier
2003-07-13 23:05           ` David Schwartz
2003-07-13 23:09             ` Davide Libenzi
2003-07-14  8:14               ` Alan Cox
2003-07-14 15:03                 ` Davide Libenzi
2003-07-14  1:27             ` Jamie Lokier
2003-07-13 21:14         ` Davide Libenzi
2003-07-13 23:05           ` David Schwartz
2003-07-13 23:11             ` Davide Libenzi
2003-07-13 23:52             ` Entrope
2003-07-14  6:14               ` David Schwartz
2003-07-14  7:20                 ` Jamie Lokier
2003-07-14  1:51             ` Jamie Lokier
2003-07-14  6:14               ` David Schwartz
2003-07-15 20:27             ` James Antill
2003-07-16  1:46               ` David Schwartz
2003-07-16  2:09                 ` James Antill
2003-07-13 13:12     ` Jamie Lokier
2003-07-13 16:55       ` Davide Libenzi
2003-07-12 20:01 ` Davide Libenzi
2003-07-13  5:24   ` David S. Miller
2003-07-13 14:07     ` Jamie Lokier
2003-07-13 17:00       ` Davide Libenzi
2003-07-13 19:15         ` Jamie Lokier
2003-07-13 23:03           ` Davide Libenzi
2003-07-14  1:41             ` Jamie Lokier
2003-07-14  2:24               ` POLLRDONCE optimisation for epoll users (was: epoll and half closed TCP connections) Jamie Lokier
2003-07-14  2:37                 ` Davide Libenzi
2003-07-14  2:43                   ` Davide Libenzi
2003-07-14  2:56                   ` Jamie Lokier
2003-07-14  3:02                     ` Davide Libenzi
2003-07-14  3:16                       ` Jamie Lokier
2003-07-14  3:21                         ` Davide Libenzi
2003-07-14  3:42                           ` Jamie Lokier
2003-07-14  4:00                             ` Davide Libenzi
2003-07-14  5:51                               ` Jamie Lokier [this message]
2003-07-14  6:24                                 ` Davide Libenzi
2003-07-14  6:57                                   ` Jamie Lokier
2003-07-14  3:12                     ` Jamie Lokier
2003-07-14  3:17                       ` Davide Libenzi
2003-07-14  3:35                         ` Jamie Lokier
2003-07-14  3:04                   ` Jamie Lokier
2003-07-14  3:12                     ` Davide Libenzi
2003-07-14  3:27                       ` Jamie Lokier
2003-07-14 17:09     ` [Patch][RFC] epoll and half closed TCP connections kuznet
2003-07-14 17:09       ` Davide Libenzi
2003-07-14 21:45       ` Jamie Lokier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030714055122.GA24031@mail.jlokier.co.uk \
    --to=jamie@shareable.org \
    --cc=davem@redhat.com \
    --cc=davidel@xmailserver.org \
    --cc=e0206@foo21.com \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).