NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/54435: reading TCP urgent data with MSG_OOB doesn't clear poll(2) status
The following reply was made to PR kern/54435; it has been noted by GNATS.
From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: Michael van Elst <mlelstv%serpens.de@localhost>
Subject: Re: kern/54435: reading TCP urgent data with MSG_OOB doesn't clear
poll(2) status
Date: Sat, 3 Aug 2019 23:51:59 +0300
On Sat, Aug 03, 2019 at 20:25:01 +0000, Michael van Elst wrote:
> OOB data is not delivered in the stream. Instead you get information
> that 'urgent data' lies ahead. recv(MSG_OOB) can be used to peek at
> that data, but it doesn't consume the stream or that data.
Can you cite a chapter and verse for that?
> The correct answer to 'urgent data' is to consume the stream to
> the point where the OOB data lies ahead. Then, since a normal
> recv() won't deliver the urgent data to the application, use
> recv(MSG_OOB) to read it. At that point, the poll condition
> already has been cleared by reading the stream.
Except that this is not what happens, as far as I can tell. Consider
the output from the test quoted in the PR:
1) we read non-urgent "a"
poll: revents = 0x1: IN
recv() = 1
a
2) At this point we have urgent "b" and there's no normal data
preceding it.
poll: revents = 0x82: PRI RDBAND
recv(MSG_OOB) = 1
b
the test "used recv(MSG_OOB) to read it".
3) "At that point, the poll condition already has been cleared by
reading the stream" - unfortunately, that's not what happens:
poll: revents = 0x82: PRI RDBAND
oobrecv: recv(MSG_OOB): Invalid argument
The test had consumed urgent "b" and tries to read further - using
MSG_OOB since that's how the test interprets POLLPRI. It fails b/c
there's no urgent data. A modified test that uses plain recv() at
this point would read (non-urgent) "c".
E.g. on linux the same test would work with
reading urgent data with MSG_OOB
poll: revents = 0x1: IN
recv() = 1
a
poll: revents = 0x2: PRI
recv(MSG_OOB) = 1
b
poll: revents = 0x1: IN
recv() = 1
c
poll: revents = 0x1: IN
recv() = 0
or, dependent on timing:
reading urgent data with MSG_OOB
poll: revents = 0x3: IN PRI
recv(MSG_OOB) = 1
b
poll: revents = 0x1: IN
recv() = 1
a
poll: revents = 0x1: IN
recv() = 1
c
poll: revents = 0x1: IN
recv() = 0
-uwe
Home |
Main Index |
Thread Index |
Old Index