> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Dave Page
> Sent: 28 July 2005 16:16
> To: Bruce Momjian; Tom Lane
> Cc: PostgreSQL-development
> Subject: Re: [HACKERS] --enable-thread-safety on Win32
>
>
> > OK, but I would then like someone to actually run the tests we do in
> > thread_test.c and make sure they _would_ pass on Win32.
>
> OK, I will work on this, and subsequently fixing configure etc.
OK, I have the thread test working with the fully pthreads library on
Windows, and everything passes except errno (well, and getpwuid which we
don't have anyway). It is supposed to be thread safe when apps are
either built against libcmt.lib or msvcrt.dll (which we use), however it
still seems to fail on Mingw. From what I can find, the 'usual' way to
make errno thread safe is by using _beginthreadex() instead of
CreateThread(), but that is done by the application of course, not libpq
(in the test case, it would be done by pthreads).
See http://www.microsoft.com/msj/0799/Win32/Win320799.aspx for a
discussion of this if interested.
However.... In all but one place in libpq, we don't use errno anyway
(actually 2, but one is a bug anyway) because we use GetLastError()
instead (which tested thread safe as well FWIW). The only place it's
used is PQoidValue():
result = strtoul(res->cmdStatus + 7, &endptr, 10);
if (!endptr || (*endptr != ' ' && *endptr != '\0') || errno ==
ERANGE) return InvalidOid;else return (Oid) result;
We don't believe strtoul() works with GetLastError() unfortunately. One
(hackish) solution would be to check that it doesn't return 0 or
ULONG_MAX.
Any suggestions?
Aside from this issue, the hacked test app, and the changes to make all
this compile are done.
Regards, Dave