[PATCH] Ensure that a blocking send() on a socket returns (with success) if a signal is handled mid-transition and SA_RESTART is not set.

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jun 6 14:23:00 GMT 2017


Hi Erik,

[vacation-induced late reply]


On May 11 16:05, Erik M. Bray wrote:
> ---
>  winsup/cygwin/fhandler_socket.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
> index f3d1d69..c7ed681 100644
> --- a/winsup/cygwin/fhandler_socket.cc
> +++ b/winsup/cygwin/fhandler_socket.cc
> @@ -1851,7 +1851,7 @@ fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags)
>  	  if (get_socket_type () != SOCK_STREAM || ret < out_len)
>  	    break;
>  	}
> -      else if (is_nonblocking () || err != WSAEWOULDBLOCK)
> +      else if (is_nonblocking () || WSAGetLastError() != WSAEWOULDBLOCK)
>  	break;
>      }

Thanks for catching!  Given that the loop isn't guaranteed to set `err'
correctly all the time, I wonder if we shouldn't get rid of `err'
completely.  Checking WSAGetLastError is plain user-space memory access
anyway, and there's no reason the compiler can't optimize this by
itself.

Also, I would prefer to have a shorter subject (<=72 chars or so) and
to describe this in the log message a bit more detailed.

Would you like to provide another patch along these lines?


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20170606/28534055/attachment.sig>


More information about the Cygwin-patches mailing list