From fe-secure.c:
> /*
> * Indicates whether the current thread is in send()
> * For use by SIGPIPE signal handlers; they should
> * ignore SIGPIPE when libpq is in send(). This means
> * that the backend has died unexpectedly.
> */
> pqbool
> PQinSend(void)
> {
> #ifdef ENABLE_THREAD_SAFETY
> return (pthread_getspecific(thread_in_send) /* has it been
> set? */ &&
> *(char *)pthread_getspecific(thread_in_send)
> == 't') ? true : false;
> #else
> return false; /* No threading, so we can't be in send() */
Why not? Signal delivery can interrupt send() even with single-threaded
users.
I really like the openssl interface: what about something like
typedef void (*pgsigpipehandler_t)(bool enable);
void PQregisterSignalCallback(pgsigpipehandler_t new);
The callback is global, and called around the send() calls.
The default handler uses the sigaction code from 7.4. The current
autodetection code is less flexible than a callback, and it's not 100%
backward compatible.
-- Manfred