summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-secure.c
diff options
context:
space:
mode:
authorBruce Momjian2005-08-23 20:48:47 +0000
committerBruce Momjian2005-08-23 20:48:47 +0000
commita970a8cb95bd3f4d3a4b924904d248c9dd322ee0 (patch)
tree4fbb5211d2a35c9e86323d1907deaf2bf63a6be2 /src/interfaces/libpq/fe-secure.c
parenteef7e30cc13158cb1fde7f4b148dd14e83331a35 (diff)
Back out incorrect commit.
Diffstat (limited to 'src/interfaces/libpq/fe-secure.c')
-rw-r--r--src/interfaces/libpq/fe-secure.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index 8f12d791acb..0852047d8db 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.68 2005/08/23 20:45:07 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.69 2005/08/23 20:48:47 momjian Exp $
*
* NOTES
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
@@ -103,12 +103,8 @@
#include <sys/stat.h>
#ifdef ENABLE_THREAD_SAFETY
-#ifdef WIN32
-#include "pthread-win32.h"
-#else
#include <pthread.h>
#endif
-#endif
#ifndef HAVE_STRDUP
#include "strdup.h"
@@ -392,21 +388,20 @@ ssize_t
pqsecure_write(PGconn *conn, const void *ptr, size_t len)
{
ssize_t n;
-
-#ifndef WIN32
+
#ifdef ENABLE_THREAD_SAFETY
sigset_t osigmask;
bool sigpipe_pending;
bool got_epipe = false;
-
if (pq_block_sigpipe(&osigmask, &sigpipe_pending) < 0)
return -1;
#else
+#ifndef WIN32
pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
-#endif /* ENABLE_THREAD_SAFETY */
-#endif /* WIN32 */
-
+#endif
+#endif
+
#ifdef USE_SSL
if (conn->ssl)
{
@@ -436,7 +431,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
if (n == -1)
{
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#ifdef ENABLE_THREAD_SAFETY
if (SOCK_ERRNO == EPIPE)
got_epipe = true;
#endif
@@ -478,19 +473,19 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
#endif
{
n = send(conn->sock, ptr, len, 0);
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#ifdef ENABLE_THREAD_SAFETY
if (n < 0 && SOCK_ERRNO == EPIPE)
got_epipe = true;
#endif
}
-
-#ifndef WIN32
+
#ifdef ENABLE_THREAD_SAFETY
pq_reset_sigpipe(&osigmask, sigpipe_pending, got_epipe);
#else
+#ifndef WIN32
pqsignal(SIGPIPE, oldsighandler);
-#endif /* ENABLE_THREAD_SAFETY */
-#endif /* WIN32 */
+#endif
+#endif
return n;
}
@@ -1237,7 +1232,7 @@ PQgetssl(PGconn *conn)
#endif /* USE_SSL */
-#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+#ifdef ENABLE_THREAD_SAFETY
/*
* Block SIGPIPE for this thread. This prevents send()/write() from exiting