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

Jamie Lokier (jamie@shareable.org)
Mon, 14 Jul 2003 07:57:41 +0100


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.
>
> Look at this :
> timeo = sock_rcvtimeo(sk, nonblock);

How does `nonblock' prevent short reads? I don't see it.

> > 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.
>
> These are streams and you can use the read(2) trick w/out problems. I
> don't think you want to mount your XML parser over UDP.

You cannot use the read(2) trick with a tty or file; RDHUP doesn't help.

> > > > (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.
>
> How, if you do not change the kernel by making it returning an extra flag ?

By defining the interface such that _not_ setting the flag merely
suppresses the optimisation, it doesn't stop the program from working.

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