8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -70,7 +70,7 @@ static SSL_CTX *SSL_context = NULL;
70
70
71
71
#define NOTIFYLIST_INITIAL_SIZE 10
72
72
#define NOTIFYLIST_GROWBY 10
73
- #define WIN32_NON_BLOCKING_CONNECTIONS
73
+
74
74
75
75
/* ----------
76
76
* Definition of the conninfo parameters and their fallback resources.
@@ -906,17 +906,7 @@ connectDBStart(PGconn *conn)
906
906
goto connect_errReturn ;
907
907
}
908
908
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 )
920
910
if (connectMakeNonblocking (conn ) == 0 )
921
911
goto connect_errReturn ;
922
912
#endif
@@ -926,23 +916,14 @@ connectDBStart(PGconn *conn)
926
916
* now, but it is possible that:
927
917
* 1. Older systems will still block on connect, despite the
928
918
* 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.
933
921
* ----------
934
922
*/
935
- #ifndef WIN32
936
923
if (connect (conn -> sock , & conn -> raddr .sa , conn -> raddr_len ) < 0 )
937
924
{
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 )
944
926
{
945
-
946
927
/*
947
928
* This is fine - we're in non-blocking mode, and the
948
929
* connection is in progress.
@@ -1040,7 +1021,7 @@ connectDBStart(PGconn *conn)
1040
1021
* This makes the connection non-blocking, for all those cases which
1041
1022
* forced us not to do it above.
1042
1023
*/
1043
- #if ((defined( WIN32 ) || defined( __CYGWIN__ )) && !defined( WIN32_NON_BLOCKING_CONNECTIONS )) || defined(USE_SSL )
1024
+ #if defined(USE_SSL )
1044
1025
if (connectMakeNonblocking (conn ) == 0 )
1045
1026
goto connect_errReturn ;
1046
1027
#endif
@@ -1949,11 +1930,13 @@ freePGconn(PGconn *conn)
1949
1930
SSL_free (conn -> ssl );
1950
1931
#endif
1951
1932
if (conn -> sock >= 0 )
1933
+ {
1952
1934
#ifdef WIN32
1953
1935
closesocket (conn -> sock );
1954
1936
#else
1955
1937
close (conn -> sock );
1956
1938
#endif
1939
+ }
1957
1940
if (conn -> pghost )
1958
1941
free (conn -> pghost );
1959
1942
if (conn -> pghostaddr )
@@ -2019,11 +2002,13 @@ closePGconn(PGconn *conn)
2019
2002
* Close the connection, reset all transient state, flush I/O buffers.
2020
2003
*/
2021
2004
if (conn -> sock >= 0 )
2005
+ {
2022
2006
#ifdef WIN32
2023
2007
closesocket (conn -> sock );
2024
2008
#else
2025
2009
close (conn -> sock );
2026
2010
#endif
2011
+ }
2027
2012
conn -> sock = -1 ;
2028
2013
conn -> status = CONNECTION_BAD ; /* Well, not really _bad_ - just
2029
2014
* absent */
0 commit comments