diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-07-20 17:45:06 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-07-20 17:45:06 +0000 |
commit | 8c79f3c4a30177e8c160fdd158813d4d8318cf5a (patch) | |
tree | ad7931e28ab84f5fc30e25239129e404880fb440 /src/interfaces/libpq/fe-connect.c | |
parent | 8f75c1b0c79868fcdde584b91e96ba05e862c255 (diff) | |
download | postgresql-8c79f3c4a30177e8c160fdd158813d4d8318cf5a.tar.gz postgresql-8c79f3c4a30177e8c160fdd158813d4d8318cf5a.zip |
i've spotted a following problem using DBD::Pg under win32. winsock
functions do not set errno, so some normal conditions are treated as
fatal errors. e.g. fetching large tuples fails, as at some point recv()
returns EWOULDBLOCK. here's a patch, which replaces errno with
WSAGetLastError(). i've tried to to affect non-win32 code.
Dmitry Yurtaev
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 82008a58c3e..2582cdee8a8 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.168 2001/07/16 20:05:51 petere Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.169 2001/07/20 17:45:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -736,9 +736,6 @@ connectNoDelay(PGconn *conn) printfPQExpBuffer(&conn->errorMessage, libpq_gettext("could not set socket to TCP no delay mode: %s\n"), strerror(errno)); -#ifdef WIN32 - printf("Winsock error: %i\n", WSAGetLastError()); -#endif return 0; } @@ -937,11 +934,7 @@ connectDBStart(PGconn *conn) */ if (connect(conn->sock, &conn->raddr.sa, conn->raddr_len) < 0) { -#ifndef WIN32 if (errno == EINPROGRESS || errno == 0) -#else - if (WSAGetLastError() == WSAEINPROGRESS) -#endif { /* @@ -2142,7 +2135,11 @@ PQrequestCancel(PGconn *conn) strcpy(conn->errorMessage.data, "PQrequestCancel() -- connection is not open\n"); conn->errorMessage.len = strlen(conn->errorMessage.data); +#ifdef WIN32 + WSASetLastError(save_errno); +#else errno = save_errno; +#endif return FALSE; } @@ -2184,11 +2181,12 @@ PQrequestCancel(PGconn *conn) /* Sent it, done */ #ifdef WIN32 closesocket(tmpsock); + WSASetLastError(save_errno); #else close(tmpsock); + errno = save_errno; #endif - errno = save_errno; return TRUE; cancel_errReturn: @@ -2199,11 +2197,12 @@ cancel_errReturn: { #ifdef WIN32 closesocket(tmpsock); + WSASetLastError(save_errno); #else close(tmpsock); + errno = save_errno; #endif } - errno = save_errno; return FALSE; } |