Web lists-archives.com

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




Hi Takashi,

(just a sidenote: it would be nice if you would send your patches
 to the cygwin-patches mailing list)

On Jun 20 22:18, Takashi Yano wrote:
> 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?

Thanks for the patch.  I had a look and your implemantation looks good
to me.  Two points:

- The minor point: There's a typo "oub-of-band" in the comment
  handling the SO_OOBINLINE ioctl.

- The major point: Now that INET and LOCAL sockets are handled
  separately, we may want to follow Linux' lead:

  "UNIX domain sockets do not support the transmission of out-of-band data
   (the MSG_OOB flag for send(2) and recv(2))" (quote from `man 7 unix')

  If I ever get around to finish the new AF_UNIX implemantation it won't
  support OOB anyway.  For the time being, we may want to disable OOB in
  fhandler_socket_local already, so, rather than duplicating the changes
  to AF_INET, we could simply disable OOB handling in
  fhandler_socket_local entirely.  Care to do that?


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature