Skip to Content.
Sympa Menu

freetds - Re: [freetds] Using freetds in Windows

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: christos AT zoulas.com (Christos Zoulas)
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Using freetds in Windows
  • Date: Mon, 11 Jan 2010 23:05:51 -0500

On Jan 11, 9:56pm, jklowden AT freetds.org ("James K. Lowden") wrote:
-- Subject: Re: [freetds] Using freetds in Windows

| Christos Zoulas wrote:
| > I think Win32 strerror(3) is threadsafe.
| >
| > Even when doing i18n?
|
| AFAIK. I don't see any technical reason why not.

Well, to be thread-safe it needs to use per-thread local storage
for the returned string since it cannot know what the string will
contain. It is easier to punt and do the simple:

char *
strerror(int num)
{
static char buf[NL_TEXTMAX];
int error = strerror_r(num, buf, sizeof(buf));
if (error)
errno = error;
return buf;
}

This is why one should be using strerror_r() if it exists, or protect
strerror() with a mutex if it does not.

christos




Archive powered by MHonArc 2.6.24.

Top of Page