public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: make sure failed sockets always signal writability
Date: Thu, 16 Jul 2020 08:58:49 +0000 (GMT)	[thread overview]
Message-ID: <20200716085849.D81A23857C4B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=aa86784937ec7868c358dd90ea5e5324f0be750d

commit aa86784937ec7868c358dd90ea5e5324f0be750d
Author: Marc Hoersken <info@marc-hoersken.de>
Date:   Wed Jul 15 20:53:21 2020 +0200

    Cygwin: make sure failed sockets always signal writability
    
    Since FD_CONNECT is only given once, we manually need to set
    FD_WRITE for connection failed sockets to have consistent
    behaviour in programs calling poll/select multiple times.
    
    Example test to non-listening port: curl -v 127.0.0.1:47

Diff:
---
 winsup/cygwin/fhandler_socket_inet.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/winsup/cygwin/fhandler_socket_inet.cc b/winsup/cygwin/fhandler_socket_inet.cc
index 74c415d60..e5b0d2d14 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -376,6 +376,12 @@ fhandler_socket_wsock::evaluate_events (const long event_mask, long &events,
       if (erase)
 	wsock_events->events &= ~(events & ~(FD_WRITE | FD_CLOSE));
     }
+  /* Since FD_CONNECT is only given once, we manually need to set
+     FD_WRITE for connection failed sockets to have consistent
+     behaviour in programs calling poll/select multiple times.
+     Example test to non-listening port: curl -v 127.0.0.1:47 */
+  if ((connect_state () == connect_failed) && (event_mask & FD_WRITE))
+    wsock_events->events |= FD_WRITE;
   UNLOCK_EVENTS;
 
   return ret;


                 reply	other threads:[~2020-07-16  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200716085849.D81A23857C4B@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).