Web lists-archives.com

Re: Problems of AF_INET domain socket regarding out-of-band data.




Hi Corinna,

On Wed, 13 Jun 2018 22:48:58 +0900
Takashi Yano wrote:
> 1. recv() with MSG_OOB flag eats normal data if no OOB data
>   is sent yet.
> 
> 2. Calling recv() with MSG_OOB flag is blocked if no OOB data
>   is sent yet.
> 
> 3. Calling recv() without MSG_OOB flag after receiving OOB data
>   is blocked even if received data exist in buffer. 

I looked into these problems and found these are due to bug of
cygwin1.dll.

Problem 1:
If recv() is called with MSG_OOB, in fhandler_socket_inet::
recv_internal(), wsamsg->dwFlags with MSG_OOB flag set is passed
to WSARecv() and this fails because no OOB data exists. At this time,
wsamsg-> dwFlags is modified by WSARecv() so that it does not have
the MSG_OOB flag. Then, WSARecv() is called again without MSG_OOB
flag in while loop. At this time, normal data is read and returned.

Problem 2:
In fhandler_socket_inet::recv_internal(), wait_for_events() is
called. This blocks the call until OOB data arrives.

Problem 3:
If recv() is called with MSG_OOB flag set, fhandler_socket_inet::
recv_internal() calls wait_for_events() with both FD_OOB and
FD_READ. If both OOB data and normal data already arrived,
not only the event of FD_OOB but also the event of FD_READ are
reset to non signaled state. I'm not sure where the signal is
reset, though.

Moreover, return value of ioctl command SIOCATMARK of winsock
is not as expected. In winsock, SIOCATMARK returns TRUE if no
OOB data exists, FALSE otherwise. This is almost opposite to
expectation.

Furthermore, inline mode (SO_OOBINLINE) of winsock is completely
broken. If SO_OOBINLINE is set, SIOATMARK always returns TRUE.
This means application cannot determine OOB data at all in inline
mode.

To solve these problems, I made a patch attached.

Could you please have a look?

-- 
Takashi Yano <takashi.yano@xxxxxxxxxxx>

Attachment: 0001-Fix-the-handling-of-out-band-data-OOB-in-a-socket.patch
Description: Binary data

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple