Re: [Slony1-general] Thread-safety detection on HP-UX

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>, Christopher Browne <cbbrowne(at)ca(dot)afilias(dot)info>, slony1-general(at)gborg(dot)postgresql(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [Slony1-general] Thread-safety detection on HP-UX
Date: 2004-10-27 03:37:28
Message-ID: 417F17F8.3040006@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 10/26/2004 6:13 PM, Bruce Momjian wrote:

> I believe Slony always needs threading, it just can be used even if the
> OS doesn't fully support all thread-safe functions, so on 8.0 you use
> --thread_safety_force. Jan, is that correct?

Yes.

Slony allways uses pthreads and therefore it requires that on platforms,
where the reentrant libc has a different definition for several global
symbols (like errno), libpq is compiled with pthread compiler flags. If
that actually leads to a "thread-safe" libpq or not is completely
irrelevant, because Slony does not need the libpq to be thread-safe.

A good example for what happens is Solaris. If libpq is compiled without
-pthreads, then "errno" is just the good old "extern int errno;". But if
it is compiled with -pthreads, then "errno" is #defined to dereferencing
the result of a function, like "*(__thread_errno())" and that function
returns the thread specific error variable and int*. Since slon is
compiled with pthreads, it links against the reentrant libc which places
error codes in the thread specific error variable. Why in devils name
that reentrant libc also has a global errno variable at all is a secret
to me and probably the last developer who knew that has left Sun 5 years
ago, but it has one and leaves it just zero all the time. Since it has
one, the extern reference errno from the non -pthread compiled libpq is
resolved just fine ... to a location of 4 wasted, meaningless bytes.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-10-27 03:39:20 Re: Strange behavior in psql
Previous Message Nick Farrell 2004-10-27 02:33:50 Sequence creation bug: 8.0.0beta4 win32