From 0150dbdce54f24596547048d4d6617d62a2570a4 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 9 Jan 2004 02:02:43 +0000 Subject: 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. --- doc/src/sgml/libpq.sgml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 248d8646af2..bfd66945f9c 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -1,5 +1,5 @@ @@ -3587,7 +3587,7 @@ thread-enabled applications. One restriction is that no two threads attempt to manipulate the same PGconn object at the same time. In particular, you cannot issue concurrent commands from different threads through the same -connection object. (If you need to run concurrent commands, start up +connection object. (If you need to run concurrent commands, use multiple connections.) @@ -3612,6 +3612,25 @@ not thread-safe.cryptthread safety It is better to use the md5 method, which is thread-safe on all platforms. + + +libpq must ignore SIGPIPE signals +generated internally by send() calls to backend processes. +When PostgreSQL is configured without +--enable-thread-safety, libpq sets +SIGPIPE to SIG_IGN before each +send() call and restores the original signal handler after +completion. When --enable-thread-safety is used, +libpq installs its own SIGPIPE handler +before the first database connection if no custom SIGPIPE +handler has been installed previously. This handler uses thread-local +storage to determine if a SIGPIPE signal has been generated +by an internal send(). If an application wants to install +its own SIGPIPE signal handler, it should call +PQinSend() to determine if it should ignore the +SIGPIPE signal. This function is available in both +thread-safe and non-thread-safe versions of libpq. + -- cgit v1.2.3