88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.170 2001/07/21 04:32:41 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.171 2001/07/31 02:14:49 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -70,7 +70,7 @@ static SSL_CTX *SSL_context = NULL;
7070
7171#define NOTIFYLIST_INITIAL_SIZE 10
7272#define NOTIFYLIST_GROWBY 10
73- #define WIN32_NON_BLOCKING_CONNECTIONS
73+
7474
7575/* ----------
7676 * Definition of the conninfo parameters and their fallback resources.
@@ -906,17 +906,7 @@ connectDBStart(PGconn *conn)
906906gotoconnect_errReturn ;
907907}
908908
909- /*
910- * Since I have no idea whether this is a valid thing to do under
911- * Windows before a connection is made, and since I have no way of
912- * testing it, I leave the code looking as below. When someone
913- * decides that they want non-blocking connections under Windows, they
914- * can define WIN32_NON_BLOCKING_CONNECTIONS before compilation. If
915- * it works, then this code can be cleaned up.
916- *
917- * Ewan Mellor <eem21@cam.ac.uk>.
918- */
919- #if ((!defined(WIN32 )&& !defined(__CYGWIN__ ))|| defined(WIN32_NON_BLOCKING_CONNECTIONS ))&& !defined(USE_SSL )
909+ #if !defined(USE_SSL )
920910if (connectMakeNonblocking (conn )== 0 )
921911gotoconnect_errReturn ;
922912#endif
@@ -926,23 +916,14 @@ connectDBStart(PGconn *conn)
926916 * now, but it is possible that:
927917 * 1. Older systems will still block on connect, despite the
928918 *non-blocking flag. (Anyone know if this is true?)
929- * 2. We are running under Windows, and aren't even trying
930- *to be non-blocking (see above).
931- * 3. We are using SSL.
932- * Thus, we have make arrangements for all eventualities.
919+ * 2. We are using SSL.
920+ * Thus, we have to make arrangements for all eventualities.
933921 * ----------
934922 */
935- #ifndef WIN32
936923if (connect (conn -> sock ,& conn -> raddr .sa ,conn -> raddr_len )< 0 )
937924{
938- if (errno == EINPROGRESS || errno == 0 )
939- #else
940- if (connect (conn -> sock ,& conn -> raddr .sa ,conn -> raddr_len )!= 0 )
941- {
942- if (errno == EINPROGRESS || errno == EWOULDBLOCK )
943- #endif
925+ if (errno == EINPROGRESS || errno == EWOULDBLOCK || errno == 0 )
944926{
945-
946927/*
947928 * This is fine - we're in non-blocking mode, and the
948929 * connection is in progress.
@@ -1040,7 +1021,7 @@ connectDBStart(PGconn *conn)
10401021 * This makes the connection non-blocking, for all those cases which
10411022 * forced us not to do it above.
10421023 */
1043- #if ((defined( WIN32 ) || defined( __CYGWIN__ )) && !defined( WIN32_NON_BLOCKING_CONNECTIONS )) || defined(USE_SSL )
1024+ #if defined(USE_SSL )
10441025if (connectMakeNonblocking (conn )== 0 )
10451026gotoconnect_errReturn ;
10461027#endif
@@ -1949,11 +1930,13 @@ freePGconn(PGconn *conn)
19491930SSL_free (conn -> ssl );
19501931#endif
19511932if (conn -> sock >=0 )
1933+ {
19521934#ifdef WIN32
19531935closesocket (conn -> sock );
19541936#else
19551937close (conn -> sock );
19561938#endif
1939+ }
19571940if (conn -> pghost )
19581941free (conn -> pghost );
19591942if (conn -> pghostaddr )
@@ -2019,11 +2002,13 @@ closePGconn(PGconn *conn)
20192002 * Close the connection, reset all transient state, flush I/O buffers.
20202003 */
20212004if (conn -> sock >=0 )
2005+ {
20222006#ifdef WIN32
20232007closesocket (conn -> sock );
20242008#else
20252009close (conn -> sock );
20262010#endif
2011+ }
20272012conn -> sock = -1 ;
20282013conn -> status = CONNECTION_BAD ;/* Well, not really _bad_ - just
20292014 * absent */