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: [EMAIL PROTECTED]
> 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
  [EMAIL PROTECTED]               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
>From [EMAIL PROTECTED] Tue Aug  5 06:13:10 2003
Return-path: <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]>; 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 [EMAIL PROTECTED])
        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 <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <[EMAIL PROTECTED]>
Date: Tue, 5 Aug 2003 11:12:54 +0100
To: Bruce Momjian <[EMAIL PROTECTED]>
Subject: --enable-thread-safety broken + patch regressions
X-Mailer: VM 7.07 under 21.4 (patch 12) "Portable Code" XEmacs Lucid
cc: Lee Kindness <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
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

Reply via email to