From: | "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk> |
---|---|
To: | "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: --enable-thread-safety on Win32 |
Date: | 2005-07-29 15:59:07 |
Message-ID: | E7F85A1B5FF8D44C8A1AF6885BC9A0E4AC963B@ratbert.vale-housing.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> -----Original Message-----
> From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-07-29 16:11:46 | Re: --enable-thread-safety on Win32 |
Previous Message | Alvaro Herrera | 2005-07-29 15:41:48 | Re: [HACKERS] Autovacuum loose ends |