Re: Mixing threaded and non-threaded

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Scott Lamb <slamb(at)slamb(dot)org>
Cc: Manfred Spraul <manfred(at)colorfullife(dot)com>, Steve Atkins <steve(at)blighty(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Mixing threaded and non-threaded
Date: 2004-01-31 20:17:13
Message-ID: 200401312017.i0VKHDl25581@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


OK, thanks.

---------------------------------------------------------------------------

Scott Lamb wrote:
> On Jan 30, 2004, at 4:53 PM, Bruce Momjian wrote:
> >> Actually, thinking about this a bit more, that might not even be
> >> necessary. Is SIGPIPE-via-(read|write) synchronous or asynchronous?
> >> (I.e., is the SIGPIPE guaranteed to arrive during the offending system
> >> call?) I was thinking not, but maybe yes. I can't seem to find a
> >> straight answer. A lot of documents seem to confuse thread-directed
> >> and
> >> synchronous, when they're not quite the same thing.
> >> SIGALRM-via-alarm()
> >> is thread-directed but obviously asynchronous.
> >
> > SIGPIPE is a sychronous signal that is called during the read() in
> > libpq. I am not sure what thread-directed is.
>
> Ahh, then the usage in libpq is safe; sorry for the false alarm. The
> concerns about signal safety are really only for async signals, as the
> behavior is undefined only when one async signal-unsafe function is
> called from a signal interrupting another:
>
> "In the presence of signals, all functions defined by this volume of
> IEEE?Std?1003.1-2001 shall behave as defined when called from or
> interrupted by a signal-catching function, with a single exception:
> when a signal interrupts an unsafe function and the signal-catching
> function calls an unsafe function, the behavior is undefined."
>
> thread-directed, by the way, simply means that the signal is directed
> at a specific thread, not just some thread in the process that doesn't
> have it masked. It's the difference between kill() and pthread_kill().
> AFAIK, all synchronous signals are thread-directed, but not all
> thread-directed signals are synchronous.
>
> Here the signal is synchronous, so the signal is guaranteed to happen
> at a safe point (during the read()), so there's no problem.
>
> Thanks,
> Scott Lamb
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-01-31 20:30:20 Re: Transaction aborts on syntax error.
Previous Message Scott Lamb 2004-01-31 20:08:45 Re: Mixing threaded and non-threaded