Re: Unixware Patch (Was: Re: Beta2 Tag'd and Bundled ...)

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Unixware Patch (Was: Re: Beta2 Tag'd and Bundled ...)
Date: 2003-09-01 21:21:10
Message-ID: 87isocfbnd.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Greg Stark <gsstark(at)mit(dot)edu> writes:
> > On the other hand, things like, getpwnam, strtok, etc have non-thread-safe
> > APIs. They can never be made thread-safe. The *_r versions of these functions
> > are standardized and required. If they don't exist then the platform simply
> > does not support threads.
>
> This statement is simply false. A platform can build thread-safe
> versions of those "unsafe" APIs if it makes the return values point
> to thread-local storage. Some BSDs do it that way. Accordingly, any
> simplistic "we must have _r to be thread-safe" approach is incorrect.

Except there are standards that describe things like strtok_r and such. If the
OS doesn't have those standard functions at all then it probably doesn't have
a thread-safe strtok.

Moreover I was somewhat disturbed when I read that in port/thread.c. It seems
rather a dramatic non-standard API change for these functions. It must break
programs and libraries that expect these to have global state accessible from
any thread. I suspect if I check back in the BSD mailing lists there were
flamewars over this at the time.

Generally I would prefer to use standards-dictated _r functions than depend on
non-standard thread-local api extensions. Especially since many platforms have
slow thread-local storage implementations.

In any case I think I'm bowing out of this discussion. It seems like a simple
matter has gotten way out of hand and I feel like a troll here. Sorry for
fueling the confusion.

--
greg

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-01 21:24:16 Re: TCP/IP with 7.4 beta2 broken?
Previous Message Tom Lane 2003-09-01 21:15:19 Re: array constructor can't construct empty array