MCPcopy Create free account
hub / github.com/apache/cloudberry / pq_reset_sigpipe

Function pq_reset_sigpipe

src/interfaces/libpq/fe-secure.c:531–557  ·  view source on GitHub ↗

* Discard any pending SIGPIPE and reset the signal mask. * * Note: we are effectively assuming here that the C library doesn't queue * up multiple SIGPIPE events. If it did, then we'd accidentally leave * ours in the queue when an event was already pending and we got another. * As long as it doesn't queue multiple events, we're OK because the caller * can't tell the difference. * * The ca

Source from the content-addressed store, hash-verified

529 * we were able to do pq_block_sigpipe(), this can't fail.
530 */
531void
532pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
533{
534 int save_errno = SOCK_ERRNO;
535 int signo;
536 sigset_t sigset;
537
538 /* Clear SIGPIPE only if none was pending */
539 if (got_epipe && !sigpipe_pending)
540 {
541 if (sigpending(&sigset) == 0 &&
542 sigismember(&sigset, SIGPIPE))
543 {
544 sigset_t sigpipe_sigset;
545
546 sigemptyset(&sigpipe_sigset);
547 sigaddset(&sigpipe_sigset, SIGPIPE);
548
549 sigwait(&sigpipe_sigset, &signo);
550 }
551 }
552
553 /* Restore saved block mask */
554 pthread_sigmask(SIG_SETMASK, osigset, NULL);
555
556 SOCK_ERRNO_SET(save_errno);
557}
558
559#endif /* ENABLE_THREAD_SAFETY && !WIN32 */

Callers 1

PQprintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected