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

Commit2b769c8

Browse files
committed
Fix residual breakage from Windows socket-errno patch: the routines
that should use regular errno, not WSAGetLastError(), now do so again.
1 parent886d7de commit2b769c8

File tree

4 files changed

+32
-38
lines changed

4 files changed

+32
-38
lines changed

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

Lines changed: 7 additions & 24 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.171 2001/07/31 02:14:49 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.172 2001/08/03 22:11:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -697,16 +697,16 @@ update_db_info(PGconn *conn)
697697
staticint
698698
connectMakeNonblocking(PGconn*conn)
699699
{
700-
#ifdefWIN32
700+
#if defined(WIN32)|| defined(__BEOS__)
701701
inton=1;
702+
#endif
702703

704+
#if defined(WIN32)
703705
if (ioctlsocket(conn->sock,FIONBIO,&on)!=0)
704706
#elif defined(__BEOS__)
705-
inton=1;
706-
707707
if (ioctl(conn->sock,FIONBIO,&on)!=0)
708708
#else
709-
if(fcntl(conn->sock,F_SETFL,O_NONBLOCK)<0)
709+
if(fcntl(conn->sock,F_SETFL,O_NONBLOCK)<0)
710710
#endif
711711
{
712712
printfPQExpBuffer(&conn->errorMessage,
@@ -1194,6 +1194,8 @@ PQconnectPoll(PGconn *conn)
11941194
caseCONNECTION_STARTED:
11951195
{
11961196
ACCEPT_TYPE_ARG3laddrlen;
1197+
intoptval;
1198+
ACCEPT_TYPE_ARG3optlen=sizeof(optval);
11971199

11981200
/*
11991201
* Write ready, since we've made it here, so the
@@ -1205,10 +1207,6 @@ PQconnectPoll(PGconn *conn)
12051207
* state waiting for us on the socket.
12061208
*/
12071209

1208-
#ifndefWIN32
1209-
intoptval;
1210-
ACCEPT_TYPE_ARG3optlen=sizeof(optval);
1211-
12121210
if (getsockopt(conn->sock,SOL_SOCKET,SO_ERROR,
12131211
(char*)&optval,&optlen)==-1)
12141212
{
@@ -1217,23 +1215,8 @@ PQconnectPoll(PGconn *conn)
12171215
strerror(errno));
12181216
gotoerror_return;
12191217
}
1220-
#else
1221-
charfaroptval[8];
1222-
ACCEPT_TYPE_ARG3optlen=sizeof(optval);
1223-
1224-
intOptResult=getsockopt(conn->sock,SOL_SOCKET,SO_ERROR,optval,&optlen);
1225-
if (OptResult==SOCKET_ERROR)
1226-
{
1227-
printfPQExpBuffer(&conn->errorMessage,
1228-
"PQconnectPoll() -- getsockopt() failed: "
1229-
"errno=%i\n",errno);
1230-
connectFailureMessage(conn,OptResult);
1231-
gotoerror_return;
1232-
}
1233-
#endif
12341218
elseif (optval!=0)
12351219
{
1236-
12371220
/*
12381221
* When using a nonblocking connect, we will typically
12391222
* see connect failures at this point, so provide a

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

Lines changed: 9 additions & 5 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-exec.c,v 1.104 2001/07/20 17:45:06 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.105 2001/08/03 22:11:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2037,6 +2037,10 @@ PQoidStatus(const PGresult *res)
20372037
returnbuf;
20382038
}
20392039

2040+
#ifdefWIN32/* need to get at normal errno here */
2041+
#undef errno
2042+
#endif
2043+
20402044
/*
20412045
PQoidValue -
20422046
a perhaps preferable form of the above which just returns
@@ -2051,11 +2055,7 @@ PQoidValue(const PGresult *res)
20512055
if (!res|| !res->cmdStatus||strncmp(res->cmdStatus,"INSERT ",7)!=0)
20522056
returnInvalidOid;
20532057

2054-
#ifdefWIN32
2055-
WSASetLastError(0);
2056-
#else
20572058
errno=0;
2058-
#endif
20592059
result=strtoul(res->cmdStatus+7,&endptr,10);
20602060

20612061
if (!endptr|| (*endptr!=' '&&*endptr!='\0')||errno==ERANGE)
@@ -2064,6 +2064,10 @@ PQoidValue(const PGresult *res)
20642064
return (Oid)result;
20652065
}
20662066

2067+
#ifdefWIN32/* back to socket errno */
2068+
#defineerrno WSAGetLastError()
2069+
#endif
2070+
20672071
/*
20682072
PQcmdTuples -
20692073
if the last command was an INSERT/UPDATE/DELETE, return number

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.35 2001/07/15 13:45:04 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.36 2001/08/03 22:11:39 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,6 +31,11 @@
3131
#include"libpq/libpq-fs.h"/* must come after sys/stat.h */
3232

3333

34+
#ifdefWIN32/* need to use normal errno in this file */
35+
#undef errno
36+
#endif
37+
38+
3439
#defineLO_BUFSIZE 8192
3540

3641
staticintlo_initialize(PGconn*conn);

‎src/interfaces/libpq/win32.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#definestrncasecmp(a,b,c) _strnicmp(a,b,c)
88

99
/*
10-
* Some compat functions
10+
* Someothercompat functions
1111
*/
1212
#defineopen(a,b,c) _open(a,b,c)
1313
#defineclose(a) _close(a)
@@ -21,18 +21,20 @@
2121
/*
2222
* crypt not available (yet)
2323
*/
24-
#definecrypt(a,b)a
24+
#definecrypt(a,b)(a)
2525

2626
/*
27-
* assumes that errno is used for sockets only
28-
*
27+
* Most of libpq uses "errno" to access error conditions from socket calls,
28+
* so on Windows we want to redirect those usages to WSAGetLastError().
29+
* Rather than #ifdef'ing every single place that has "errno", hack it up
30+
* with a macro instead. But there are a few places that do need to touch
31+
* the regular errno variable. For them, we #undef and then redefine errno.
2932
*/
3033

31-
#undef errno
32-
#undef EINTR
33-
#undef EAGAIN/* doesn't apply on sockets */
34-
3534
#defineerrno WSAGetLastError()
35+
36+
#undef EAGAIN/* doesn't apply on sockets */
37+
#undef EINTR
3638
#defineEINTR WSAEINTR
3739
#defineEWOULDBLOCK WSAEWOULDBLOCK
3840
#defineECONNRESET WSAECONNRESET

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp