From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id D81A23857C4B; Thu, 16 Jul 2020 08:58:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D81A23857C4B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: make sure failed sockets always signal writability X-Act-Checkin: newlib-cygwin X-Git-Author: Marc Hoersken X-Git-Refname: refs/heads/master X-Git-Oldrev: b1237e64fd03a3b802b9fedde298505e22b3f07f X-Git-Newrev: aa86784937ec7868c358dd90ea5e5324f0be750d Message-Id: <20200716085849.D81A23857C4B@sourceware.org> Date: Thu, 16 Jul 2020 08:58:49 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Jul 2020 08:58:49 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=aa86784937ec7868c358dd90ea5e5324f0be750d commit aa86784937ec7868c358dd90ea5e5324f0be750d Author: Marc Hoersken 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;