Обсуждение: threads/UnixWare
In src/port, we have in threads.c:
/** Wrapper around getpwuid() or getpwuid_r() to mimic POSIX getpwuid_r()* behaviour, if it is not available.*/
int
pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer, size_t buflen, struct passwd **
result)
{
#if defined(USE_THREADS) && defined(HAVE_GETPWUID_R)
/* * broken (well early POSIX draft) getpwuid_r() which returns
'struct * passwd *' */ *result = getpwuid_r(uid, resultbuf, buffer, buflen);
#else /* no getpwuid_r() available, just use getpwuid() */ *result = getpwuid(uid);
#endif return (*result == NULL) ? -1 : 0;
}
Which BREAKS if you have the correct getpwuid_r() like UnixWare does.
Can someone help me with the configure checks/macros I need?
$ grep getpwuid_r /usr/include/pwd.h
int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
$
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Actually, your getpwuid_r is the old, pre-POSIX format. The attached
email has the configure tests. I was hoping we wouldn't need them, but
it seems we may.
---------------------------------------------------------------------------
Larry Rosenman wrote:
> In src/port, we have in threads.c:
>
> /*
> * Wrapper around getpwuid() or getpwuid_r() to mimic POSIX getpwuid_r()
> * behaviour, if it is not available.
> */
> int
> pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
> size_t buflen, struct passwd ** result)
> {
> #if defined(USE_THREADS) && defined(HAVE_GETPWUID_R)
>
> /*
> * broken (well early POSIX draft) getpwuid_r() which returns
> 'struct
> * passwd *'
> */
> *result = getpwuid_r(uid, resultbuf, buffer, buflen);
> #else
> /* no getpwuid_r() available, just use getpwuid() */
> *result = getpwuid(uid);
> #endif
> return (*result == NULL) ? -1 : 0;
> }
>
>
> Which BREAKS if you have the correct getpwuid_r() like UnixWare does.
>
> Can someone help me with the configure checks/macros I need?
> $ grep getpwuid_r /usr/include/pwd.h
> int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
> $
>
>
>
>
> --
> Larry Rosenman http://www.lerctr.org/~ler
> Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
> US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
--On Friday, August 08, 2003 02:10:25 -0400 Bruce Momjian <pgman@candle.pha.pa.us> wrote: > > Actually, your getpwuid_r is the old, pre-POSIX format. The attached > email has the configure tests. I was hoping we wouldn't need them, but > it seems we may. Err, SCO claims SUSv2, the Single Unix Specification Version 2. V3 **JUST** came out. I'll look at Lee's stuff. -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Bruce Momjian writes: > Actually, your getpwuid_r is the old, pre-POSIX format. No, his is the right POSIX/SUS variant. -- Peter Eisentraut peter_e@gmx.net
I've not been keeping up with the thread re who has what version of getpwuid_r... But just to clarify things the "right" version is: int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result); documented at: http://www.opengroup.org/onlinepubs/007904975/functions/getpwuid.html My email to Bruce which he tacked onto his reply is a good summary of the current problems with the thread stuff. L. Larry Rosenman writes:> > > --On Friday, August 08, 2003 02:10:25 -0400 Bruce Momjian > <pgman@candle.pha.pa.us> wrote:>> >> > Actually, your getpwuid_r is the old, pre-POSIX format. The attached> > email has the configure tests. Iwas hoping we wouldn't need them, but> > it seems we may.> Err, SCO claims SUSv2, the Single Unix Specification Version2. V3 > **JUST** came> out.> > I'll look at Lee's stuff.> > > > > > -- > Larry Rosenman http://www.lerctr.org/~ler>Phone: +1 972-414-9812 E-Mail: ler@lerctr.org> US Mail: 1905 Steamboat SpringsDrive, Garland, TX 75044-6749>
--On Friday, August 08, 2003 11:53:34 +0100 Lee Kindness <lkindness@csl.co.uk> wrote: > I've not been keeping up with the thread re who has what version of > getpwuid_r... But just to clarify things the "right" version is: > > int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, > size_t bufsize, struct passwd **result); > > documented at: > > http://www.opengroup.org/onlinepubs/007904975/functions/getpwuid.html > > My email to Bruce which he tacked onto his reply is a good summary of > the current problems with the thread stuff. Ok. Lee: Did you see the patch I posted? Can you help on the configure test(s) needed to set HAVE_POSIX_GETPWUID_R? I **THINK** I did the patch right to handle it if it's set. I forced it for UnixWare and it seems to work. LER > > L. > > Larry Rosenman writes: > > > > > > --On Friday, August 08, 2003 02:10:25 -0400 Bruce Momjian > > <pgman@candle.pha.pa.us> wrote: > > > > > > > > Actually, your getpwuid_r is the old, pre-POSIX format. The attached > > > email has the configure tests. I was hoping we wouldn't need them, > but > > it seems we may. > > Err, SCO claims SUSv2, the Single Unix Specification Version 2. V3 > > **JUST** came > > out. > > > > I'll look at Lee's stuff. > > > > > > > > > > > > -- > > Larry Rosenman http://www.lerctr.org/~ler > > Phone: +1 972-414-9812 E-Mail: ler@lerctr.org > > US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 > > -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
Larry, haven't managed to look at that patch... But stuffed for time just now - just about to head off for the weekend. I'm hoping to spend a bit of time on this on Tuesday! So, i'll see how things have progressed then. L. Larry Rosenman writes:> --On Friday, August 08, 2003 11:53:34 +0100 Lee Kindness > > I've not been keeping up with the threadre who has what version of> > getpwuid_r... But just to clarify things the "right" version is:> >> > int getpwuid_r(uid_tuid, struct passwd *pwd, char *buffer,> > size_t bufsize, struct passwd **result);> >> >documented at:> >> > http://www.opengroup.org/onlinepubs/007904975/functions/getpwuid.html> >> > My email to Bruce whichhe tacked onto his reply is a good summary of> > the current problems with the thread stuff.> Ok. Lee: Did you seethe patch I posted? Can you help on the configure > test(s)> needed to set HAVE_POSIX_GETPWUID_R?> > I **THINK** I didthe patch right to handle it if it's set. I forced it > for UnixWare> and it seems to work.> > Larry Rosenman writes:>> > --On Friday, August 08, 2003 02:10:25 -0400 Bruce Momjian> > > <pgman@candle.pha.pa.us> wrote:> > > > Actually,your getpwuid_r is the old, pre-POSIX format. The attached> > > > email has the configure tests. I was hopingwe wouldn't need them,> > but > > it seems we may.> > > Err, SCO claims SUSv2, the Single Unix Specification Version2. V3> > > **JUST** came> > > out.> > >> > > I'll look at Lee's stuff.
Of course, I was wrong. In fact, the patch below actually said it was
the pre-POSIX version of getpwuid_r().
---------------------------------------------------------------------------
Bruce Momjian wrote:
>
> Actually, your getpwuid_r is the old, pre-POSIX format. The attached
> email has the configure tests. I was hoping we wouldn't need them, but
> it seems we may.
>
> ---------------------------------------------------------------------------
>
> Larry Rosenman wrote:
> > In src/port, we have in threads.c:
> >
> > /*
> > * Wrapper around getpwuid() or getpwuid_r() to mimic POSIX getpwuid_r()
> > * behaviour, if it is not available.
> > */
> > int
> > pqGetpwuid(uid_t uid, struct passwd * resultbuf, char *buffer,
> > size_t buflen, struct passwd ** result)
> > {
> > #if defined(USE_THREADS) && defined(HAVE_GETPWUID_R)
> >
> > /*
> > * broken (well early POSIX draft) getpwuid_r() which returns
> > 'struct
> > * passwd *'
> > */
> > *result = getpwuid_r(uid, resultbuf, buffer, buflen);
> > #else
> > /* no getpwuid_r() available, just use getpwuid() */
> > *result = getpwuid(uid);
> > #endif
> > return (*result == NULL) ? -1 : 0;
> > }
> >
> >
> > Which BREAKS if you have the correct getpwuid_r() like UnixWare does.
> >
> > Can someone help me with the configure checks/macros I need?
> > $ grep getpwuid_r /usr/include/pwd.h
> > int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
> > $
> >
> >
> >
> >
> > --
> > Larry Rosenman http://www.lerctr.org/~ler
> > Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
> > US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 8: explain analyze is your friend
> >
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman@candle.pha.pa.us | (610) 359-1001
> + If your life is a hard drive, | 13 Roberts Road
> + Christ can be your backup. | Newtown Square, Pennsylvania 19073
> >From lkind@csl.co.uk Tue Aug 5 06:13:10 2003
> Return-path: <lkind@csl.co.uk>
> Received: from internet.csl.co.uk (internet.csl.co.uk [194.130.52.3])
> by candle.pha.pa.us (8.11.6/8.11.6) with ESMTP id h75AD8r29374
> for <pgman@candle.pha.pa.us>; Tue, 5 Aug 2003 06:13:09 -0400 (EDT)
> Received: from euphrates.csl.co.uk (host-194-67.csl.co.uk [194.130.52.67])
> by internet.csl.co.uk (8.12.8/8.12.8) with ESMTP id h75AD284032695;
> Tue, 5 Aug 2003 11:13:02 +0100
> Received: from kelvin.csl.co.uk by euphrates.csl.co.uk (8.9.3/ConceptI 2.4)
> id LAA21628; Tue, 5 Aug 2003 11:13:00 +0100 (BST)
> Received: from kelvin.csl.co.uk (localhost.localdomain [127.0.0.1])
> by kelvin.csl.co.uk (8.12.8/8.12.8) with ESMTP id h75ACxU1028659;
> Tue, 5 Aug 2003 11:12:59 +0100
> Received: (from lkind@localhost)
> by kelvin.csl.co.uk (8.12.8/8.12.8/Submit) id h75ACsBW028655;
> Tue, 5 Aug 2003 11:12:54 +0100
> From: Lee Kindness <lkindness@csl.co.uk>
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> Message-ID: <16175.33574.361948.57279@kelvin.csl.co.uk>
> Date: Tue, 5 Aug 2003 11:12:54 +0100
> To: Bruce Momjian <pgman@candle.pha.pa.us>
> Subject: --enable-thread-safety broken + patch regressions
> X-Mailer: VM 7.07 under 21.4 (patch 12) "Portable Code" XEmacs Lucid
> cc: Lee Kindness <lkindness@csl.co.uk>, pgsql-hackers@postgresql.org
> Status: OR
>
> Bruce, the changes you made yesterday to configure for
> --enable-thread-safety have broken the build, at least for Linux on
> Redhat 9.
>
> Also, I took the opportunity to look at port/threads.c. It is missing
> important functionality compaired to the patch I originally
> submitted. For getpwuid_r, gethostbyname_r and strerror_r there are
> three possible scenarios:
>
> 1. The OS doesn't have it (but the non _r function can still be thread
> safe (i.e. HPUX 11)).
>
> 2. The OS has it, but the implmentation doesn't match the POSIX spec.
>
> 3. The OS has it, and the implmentation matches the POSIX spec.
>
> Case 3 is not being considered. In my original patch this was handled
> by the pqGetpwuid etc functions simply being defined to getpwuid_r
> (except for pqStrerror).
>
> I remember discussing with you that the implementation of pqStrerror
> didn't really need the distinction between the two _r
> versions. However I think the others do, and the native/correct _r
> calls should be #defined in if they match the POSIX spec.
>
> It's also worth considering that when the _r function is available AND
> the normal function is also thread-safe then the _r version should
> still be used since it has a clean API which removes unneeded locking
> within the old function.
>
> I've still got the latest (and earlier with some configure work)
> patches I submitted up at:
>
> http://services.csl.co.uk/postgresql/
>
> Thanks, Lee.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
-- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610)
359-1001+ If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square,
Pennsylvania19073