Re: threads/UnixWare

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Larry Rosenman <ler(at)lerctr(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: threads/UnixWare
Date: 2003-08-12 03:20:49
Message-ID: 200308120320.h7C3Knc06961@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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(at)lerctr(dot)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(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

> >From lkind(at)csl(dot)co(dot)uk Tue Aug 5 06:13:10 2003
> Return-path: <lkind(at)csl(dot)co(dot)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(at)candle(dot)pha(dot)pa(dot)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(at)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(at)csl(dot)co(dot)uk>
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> Message-ID: <16175(dot)33574(dot)361948(dot)57279(at)kelvin(dot)csl(dot)co(dot)uk>
> Date: Tue, 5 Aug 2003 11:12:54 +0100
> To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(at)csl(dot)co(dot)uk>, pgsql-hackers(at)postgresql(dot)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(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 Bruce Momjian 2003-08-12 04:07:12 Re: On Linux Filesystems
Previous Message Christopher Browne 2003-08-12 02:58:18 On Linux Filesystems