aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-print.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2004-01-09 02:02:43 +0000
committerBruce Momjian <bruce@momjian.us>2004-01-09 02:02:43 +0000
commit0150dbdce54f24596547048d4d6617d62a2570a4 (patch)
treeb2093a0e2efb39f29ce45bc3464b25dd6b298fba /src/interfaces/libpq/fe-print.c
parentacc57543debdd2de93c2c5df31702ef8ecd461b5 (diff)
downloadpostgresql-0150dbdce54f24596547048d4d6617d62a2570a4.tar.gz
postgresql-0150dbdce54f24596547048d4d6617d62a2570a4.zip
Allow libpq to do thread-safe SIGPIPE handling. This allows it to
ignore SIGPIPE from send() in libpq, but terminate on any other SIGPIPE, unless the user installs their own signal handler. This is a minor fix because the only time you get SIGPIPE from libpq's send() is when the backend dies.
Diffstat (limited to 'src/interfaces/libpq/fe-print.c')
-rw-r--r--src/interfaces/libpq/fe-print.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index b7fa71b1b72..9afa1294e6f 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -10,7 +10,7 @@
* didn't really belong there.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.49 2003/11/29 19:52:12 pgsql Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.50 2004/01/09 02:02:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -90,8 +90,10 @@ PQprint(FILE *fout,
int fs_len = strlen(po->fieldSep);
int total_line_length = 0;
int usePipe = 0;
- pqsigfunc oldsigpipehandler = NULL;
char *pagerenv;
+#if !defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
+ pqsigfunc oldsigpipehandler = NULL;
+#endif
#ifdef TIOCGWINSZ
struct winsize screen_size;
@@ -189,9 +191,13 @@ PQprint(FILE *fout,
if (fout)
{
usePipe = 1;
+#ifdef ENABLE_THREAD_SAFETY
+ pthread_setspecific(thread_in_send, "t");
+#else
#ifndef WIN32
oldsigpipehandler = pqsignal(SIGPIPE, SIG_IGN);
#endif
+#endif
}
else
fout = stdout;
@@ -306,8 +312,14 @@ PQprint(FILE *fout,
_pclose(fout);
#else
pclose(fout);
+#endif
+#ifdef ENABLE_THREAD_SAFETY
+ pthread_setspecific(thread_in_send, "f");
+#else
+#ifndef WIN32
pqsignal(SIGPIPE, oldsigpipehandler);
#endif
+#endif
}
if (po->html3 && !po->expanded)
fputs("</table>\n", fout);