diff options
Diffstat (limited to 'src/interfaces/libpq/fe-misc.c')
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index a8af4d893ab..15b6dcb1e53 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -25,7 +25,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.72 2002/06/14 04:09:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.73 2002/06/14 04:23:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,6 +55,9 @@ #include "mb/pg_wchar.h" #endif +extern void secure_close(PGconn *); +extern ssize_t secure_read(PGconn *, void *, size_t); +extern ssize_t secure_write(PGconn *, const void *, size_t); #define DONOTICE(conn,message) \ ((*(conn)->noticeHook) ((conn)->noticeArg, (message))) @@ -477,14 +480,8 @@ pqReadData(PGconn *conn) /* OK, try to read some data */ retry3: -#ifdef USE_SSL - if (conn->ssl) - nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd, - conn->inBufSize - conn->inEnd); - else -#endif - nread = recv(conn->sock, conn->inBuffer + conn->inEnd, - conn->inBufSize - conn->inEnd, 0); + nread = secure_read(conn, conn->inBuffer + conn->inEnd, + conn->inBufSize - conn->inEnd); if (nread < 0) { if (SOCK_ERRNO == EINTR) @@ -563,14 +560,8 @@ retry3: * arrived. */ retry4: -#ifdef USE_SSL - if (conn->ssl) - nread = SSL_read(conn->ssl, conn->inBuffer + conn->inEnd, - conn->inBufSize - conn->inEnd); - else -#endif - nread = recv(conn->sock, conn->inBuffer + conn->inEnd, - conn->inBufSize - conn->inEnd, 0); + nread = secure_read(conn, conn->inBuffer + conn->inEnd, + conn->inBufSize - conn->inEnd); if (nread < 0) { if (SOCK_ERRNO == EINTR) @@ -611,6 +602,7 @@ definitelyFailed: "\tThis probably means the server terminated abnormally\n" "\tbefore or while processing the request.\n")); conn->status = CONNECTION_BAD; /* No more connection to backend */ + secure_close(conn); #ifdef WIN32 closesocket(conn->sock); #else @@ -650,23 +642,9 @@ pqSendSome(PGconn *conn) /* while there's still data to send */ while (len > 0) { - /* Prevent being SIGPIPEd if backend has closed the connection. */ -#ifndef WIN32 - pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); -#endif - int sent; -#ifdef USE_SSL - if (conn->ssl) - sent = SSL_write(conn->ssl, ptr, len); - else -#endif - sent = send(conn->sock, ptr, len, 0); - -#ifndef WIN32 - pqsignal(SIGPIPE, oldsighandler); -#endif + sent = secure_write(conn, ptr, len); if (sent < 0) { |