Re: SIGPIPE handling, take two.

Поиск
Список
Период
Сортировка
От Gaetano Mendola
Тема Re: SIGPIPE handling, take two.
Дата
Msg-id 3FB0B7CB.2070602@bigfoot.com
обсуждение исходный текст
Ответ на Re: SIGPIPE handling, take two.  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: SIGPIPE handling, take two.  (Gaetano Mendola <mendola@bigfoot.com>)
Список pgsql-patches
Bruce Momjian wrote:
> I think this is the patch I like.  It does the auto-detect handling as I
> hoped.  I will just do the doc updates to mention it.
>
> My only issue is that this is per-connection, while I think you have to
> create a global variable that defaults to false, and on first connect,
> check, and not after.  Based on the code below, a second connection
> would  have the SIGPIPE signal set to SIG_IGN, not SIG_DEF, and you
> would be back to setting SIG_IGN around each send, even though it was
> already set.
>
> Are others OK with this too?

I believe that the are some errors on the following code:

#if !defined(HAVE_POSIX_SIGNALS)
      {
          pqsigfunc old;
           old = signal(SIGPIPE, SIG_IGN);
          if (old != SIG_DFL)
              conn->do_sigaction = false;
          signal(SIGPIPE, old);
      }
#else
    {
          struct sigaction oact;

          if (sigaction(SIGPIPE, NULL, &oact) == 0 && oact.sa_handler != SIG_DFL)
              conn->do_sigaction = false;
      }
#endif   /* !HAVE_POSIX_SIGNALS */

the old signal handler is not reinstated in case of
HAVE_POSIX_SIGNAL

May be this sound better:


#if !defined(HAVE_POSIX_SIGNALS)
      {
          pqsigfunc old;
           old = signal(SIGPIPE, SIG_IGN);
          if (old != SIG_DFL && old != SIG_ERR)
              conn->do_sigaction = false;

        if ( old != SIG_ERR )
            signal(SIGPIPE, old);

      }
#else
    {
          struct sigaction oact;
        int err;

          if ( (err = sigaction(SIGPIPE, NULL, &oact)) == 0 &&
                     oact.sa_handler != SIG_DFL)
              conn->do_sigaction = false;

        if ( err == 0 )
            sigaction(SIGPIPE, &oact, NULL);

      }
#endif   /* !HAVE_POSIX_SIGNALS */



Regards
Gaetano Mendola














В списке pgsql-patches по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: SIGPIPE handling, take two.
Следующее
От: Gaetano Mendola
Дата:
Сообщение: Re: SIGPIPE handling, take two.