From 657c0cf4897b8ee11f1138b800a014c1461bc20d Mon Sep 17 00:00:00 2001
From: dgp <dgp@users.sourceforge.net>
Date: Thu, 3 May 2012 18:28:11 +0000
Subject: 3428753 Fix [socket -async] connections that manage to connect
 synchronously.

---
 ChangeLog          | 5 +++++
 unix/tclUnixSock.c | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7623d59..fd02eff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-03  Don Porter  <dgp@users.sourceforge.net>
+
+	* unix/tclUnixSock.c:	[Bug 3428753] Fix [socket -async] connections
+	that manage to connect synchronously.
+
 2012-05-02  Jan Nijtmans  <nijtmans@users.sf.net>
 
 	* generic/configure.in:    Better detection and implementation for cpuid
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 8c94e7f..04cfe66 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -1030,7 +1030,8 @@ CreateClientSocket(
                 state->status = status;
             }
 	    if (status == 0) {
-                goto out;
+		CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
+		goto out;
 	    }
 	}
     }
@@ -1041,7 +1042,6 @@ out:
         /*
          * An asynchonous connection has finally succeeded or failed.
          */
-        CLEAR_BITS(state->flags, TCP_ASYNC_CONNECT);
         TcpWatchProc(state, state->filehandlers);
         TclUnixSetBlockingMode(state->fds.fd, state->cachedBlocking);
 
-- 
cgit v0.12

