1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

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.
This commit is contained in:
Bruce Momjian
2004-01-09 02:02:43 +00:00
parent acc57543de
commit 0150dbdce5
9 changed files with 167 additions and 12 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.266 2004/01/07 18:56:29 neilc Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.267 2004/01/09 02:02:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -43,6 +43,10 @@
#include <arpa/inet.h>
#endif
#ifdef ENABLE_THREAD_SAFETY
#include <pthread.h>
#endif
#include "libpq/ip.h"
#include "mb/pg_wchar.h"
@ -66,7 +70,6 @@ long ioctlsocket_ret=1;
#define DefaultSSLMode "disable"
#endif
/* ----------
* Definition of the conninfo parameters and their fallback resources.
*
@ -198,6 +201,7 @@ static char *pwdfMatchesString(char *buf, char *token);
static char *PasswordFromFile(char *hostname, char *port, char *dbname,
char *username);
/*
* Connecting to a Database
*
@ -881,6 +885,12 @@ connectDBStart(PGconn *conn)
struct addrinfo hint;
const char *node = NULL;
int ret;
#ifdef ENABLE_THREAD_SAFETY
static pthread_once_t check_sigpipe_once = PTHREAD_ONCE_INIT;
/* Check only on first connection request */
pthread_once(&check_sigpipe_once, check_sigpipe_handler);
#endif
if (!conn)
return 0;
@ -3158,3 +3168,4 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
#undef LINELEN
}