Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca5a516

Browse files
committed
I downloaded new source for lib (only few hours old !!!), and made
changes on this new source to make non-blocking connection work. Itested it, and PQSendQuery and PQGetResult are working fine.In win32.h I added one line:#define snprintf _snprintfDarko Prenosil
1 parent54bf5da commitca5a516

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.169 2001/07/20 17:45:05 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.170 2001/07/21 04:32:41 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -70,7 +70,7 @@ static SSL_CTX *SSL_context = NULL;
7070

7171
#defineNOTIFYLIST_INITIAL_SIZE 10
7272
#defineNOTIFYLIST_GROWBY 10
73-
73+
#defineWIN32_NON_BLOCKING_CONNECTIONS
7474

7575
/* ----------
7676
* Definition of the conninfo parameters and their fallback resources.
@@ -932,9 +932,15 @@ connectDBStart(PGconn *conn)
932932
* Thus, we have make arrangements for all eventualities.
933933
* ----------
934934
*/
935+
#ifndefWIN32
935936
if (connect(conn->sock,&conn->raddr.sa,conn->raddr_len)<0)
936937
{
937938
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
938944
{
939945

940946
/*
@@ -1208,15 +1214,6 @@ PQconnectPoll(PGconn *conn)
12081214
{
12091215
ACCEPT_TYPE_ARG3laddrlen;
12101216

1211-
#ifndefWIN32
1212-
intoptval;
1213-
1214-
#else
1215-
charoptval;
1216-
1217-
#endif
1218-
ACCEPT_TYPE_ARG3optlen=sizeof(optval);
1219-
12201217
/*
12211218
* Write ready, since we've made it here, so the
12221219
* connection has been made.
@@ -1227,6 +1224,10 @@ PQconnectPoll(PGconn *conn)
12271224
* state waiting for us on the socket.
12281225
*/
12291226

1227+
#ifndefWIN32
1228+
intoptval;
1229+
ACCEPT_TYPE_ARG3optlen=sizeof(optval);
1230+
12301231
if (getsockopt(conn->sock,SOL_SOCKET,SO_ERROR,
12311232
(char*)&optval,&optlen)==-1)
12321233
{
@@ -1235,6 +1236,20 @@ PQconnectPoll(PGconn *conn)
12351236
strerror(errno));
12361237
gotoerror_return;
12371238
}
1239+
#else
1240+
charfaroptval[8];
1241+
ACCEPT_TYPE_ARG3optlen=sizeof(optval);
1242+
1243+
intOptResult=getsockopt(conn->sock,SOL_SOCKET,SO_ERROR,optval,&optlen);
1244+
if (OptResult==SOCKET_ERROR)
1245+
{
1246+
printfPQExpBuffer(&conn->errorMessage,
1247+
"PQconnectPoll() -- getsockopt() failed: "
1248+
"errno=%i\n",errno);
1249+
connectFailureMessage(conn,OptResult);
1250+
gotoerror_return;
1251+
}
1252+
#endif
12381253
elseif (optval!=0)
12391254
{
12401255

‎src/interfaces/libpq/win32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#definepopen(a,b) _popen(a,b)
1717
#definepclose(a) _pclose(a)
1818
#definevsnprintf(a,b,c,d) _vsnprintf(a,b,c,d)
19+
#definesnprintf _snprintf
1920

2021
/*
2122
* crypt not available (yet)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp