1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-22 21:53:06 +03:00

Make libpq thread-safe with configure --with-threads option.

Lee Kindness
This commit is contained in:
Bruce Momjian
2003-06-14 17:49:54 +00:00
parent 62b532b736
commit a16a031411
10 changed files with 146 additions and 71 deletions

View File

@@ -271,13 +271,12 @@ struct MessageDLL
*/
const char *
winsock_strerror(int err)
winsock_strerror(int err, char *strerrbuf, size_t buflen)
{
static char buf[512]; /* Not threadsafe */
unsigned long flags;
int offs,
i;
int success = LookupWSErrorMessage(err, buf);
int success = LookupWSErrorMessage(err, strerrbuf);
for (i = 0; !success && i < DLLS_SIZE; i++)
{
@@ -302,20 +301,20 @@ winsock_strerror(int err)
flags,
dlls[i].handle, err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
buf, sizeof(buf) - 64,
strerrbuf, buflen - 64,
0
);
}
if (!success)
sprintf(buf, "Unknown socket error (0x%08X/%lu)", err, err);
sprintf(strerrbuf, "Unknown socket error (0x%08X/%lu)", err, err);
else
{
buf[sizeof(buf) - 1] = '\0';
offs = strlen(buf);
if (offs > sizeof(buf) - 64)
offs = sizeof(buf) - 64;
sprintf(buf + offs, " (0x%08X/%lu)", err, err);
strerrbuf[buflen - 1] = '\0';
offs = strlen(strerrbuf);
if (offs > buflen - 64)
offs = buflen - 64;
sprintf(strerrbuf + offs, " (0x%08X/%lu)", err, err);
}
return buf;
return strerrbuf;
}