55 #define SIGPIPE_MASKED(conn) ((conn)->sigpipe_so || (conn)->sigpipe_flag)
64 #define DECLARE_SIGPIPE_INFO(spinfo) struct sigpipe_info spinfo
66 #define DISABLE_SIGPIPE(conn, spinfo, failaction) \
68 (spinfo).got_epipe = false; \
69 if (!SIGPIPE_MASKED(conn)) \
71 if (pq_block_sigpipe(&(spinfo).oldsigmask, \
72 &(spinfo).sigpipe_pending) < 0) \
77 #define REMEMBER_EPIPE(spinfo, cond) \
80 (spinfo).got_epipe = true; \
83 #define RESTORE_SIGPIPE(conn, spinfo) \
85 if (!SIGPIPE_MASKED(conn)) \
86 pq_reset_sigpipe(&(spinfo).oldsigmask, (spinfo).sigpipe_pending, \
87 (spinfo).got_epipe); \
91 #define DECLARE_SIGPIPE_INFO(spinfo)
92 #define DISABLE_SIGPIPE(conn, spinfo, failaction)
93 #define REMEMBER_EPIPE(spinfo, cond)
94 #define RESTORE_SIGPIPE(conn, spinfo)
196 int result_errno = 0;
208 switch (result_errno)
213 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
223 "\tThis probably means the server terminated abnormally\n"
224 "\tbefore or while processing the request.");
235 sebuf,
sizeof(sebuf)));
320 int result_errno = 0;
338 flags |= MSG_NOSIGNAL;
357 if (flags != 0 && result_errno == EINVAL)
366 switch (result_errno)
371 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
390 "\tThis probably means the server terminated abnormally\n"
391 "\tbefore or while processing the request."));
393 strlcat(msgbuf,
"\n",
sizeof(msgbuf));
406 sebuf,
sizeof(sebuf)));
408 strlcat(msgbuf,
"\n",
sizeof(msgbuf));
448 static const char *
const result[] = {NULL};
506 sigset_t sigpipe_sigset;
509 sigemptyset(&sigpipe_sigset);
510 sigaddset(&sigpipe_sigset,
SIGPIPE);
513 SOCK_ERRNO_SET(pthread_sigmask(SIG_BLOCK, &sigpipe_sigset, osigset));
518 if (sigismember(osigset,
SIGPIPE))
521 if (sigpending(&sigset) != 0)
524 if (sigismember(&sigset,
SIGPIPE))
525 *sigpipe_pending =
true;
527 *sigpipe_pending =
false;
530 *sigpipe_pending =
false;
561 if (got_epipe && !sigpipe_pending)
563 if (sigpending(&sigset) == 0 &&
566 sigset_t sigpipe_sigset;
568 sigemptyset(&sigpipe_sigset);
569 sigaddset(&sigpipe_sigset,
SIGPIPE);
571 sigwait(&sigpipe_sigset, &signo);
576 pthread_sigmask(SIG_SETMASK, osigset, NULL);
void libpq_append_conn_error(PGconn *conn, const char *fmt,...)
ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len)
ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len)
PostgresPollingStatusType pgtls_open_client(PGconn *conn)
ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len)
ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len)
void pgtls_close(PGconn *conn)
ssize_t pqsecure_write(PGconn *conn, const void *ptr, size_t len)
void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
void PQinitSSL(int do_init)
PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void)
#define REMEMBER_EPIPE(spinfo, cond)
int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
PostgresPollingStatusType pqsecure_open_client(PGconn *conn)
int PQgssEncInUse(PGconn *conn)
#define DISABLE_SIGPIPE(conn, spinfo, failaction)
void PQinitOpenSSL(int do_ssl, int do_crypto)
int PQsslInUse(PGconn *conn)
ssize_t pqsecure_read(PGconn *conn, void *ptr, size_t len)
ssize_t pqsecure_raw_read(PGconn *conn, void *ptr, size_t len)
ssize_t pqsecure_raw_write(PGconn *conn, const void *ptr, size_t len)
const char *const * PQsslAttributeNames(PGconn *conn)
void * PQgetssl(PGconn *conn)
void * PQsslStruct(PGconn *conn, const char *struct_name)
void * PQgetgssctx(PGconn *conn)
void pqsecure_close(PGconn *conn)
const char * PQsslAttribute(PGconn *conn, const char *attribute_name)
#define DECLARE_SIGPIPE_INFO(spinfo)
void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook)
#define RESTORE_SIGPIPE(conn, spinfo)
int(* PQsslKeyPassHook_OpenSSL_type)(char *buf, int size, PGconn *conn)
PostgresPollingStatusType
#define SOCK_ERRNO_SET(e)
static void do_init(void)
#define PG_STRERROR_R_BUFLEN
size_t strlcat(char *dst, const char *src, size_t siz)
static pg_noinline void Size size
#define recv(s, buf, len, flags)
#define send(s, buf, len, flags)