diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-06-14 17:49:54 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-06-14 17:49:54 +0000 |
commit | a16a0314114f7e6e4414d11f6ff2744496952bda (patch) | |
tree | 453187eb6cf695da32e516fbd9c3d1ad6f2fa9ed /src/interfaces/libpq/win32.c | |
parent | 62b532b73668267eb950f1ba8fed4a8ec45f60ae (diff) | |
download | postgresql-a16a0314114f7e6e4414d11f6ff2744496952bda.tar.gz postgresql-a16a0314114f7e6e4414d11f6ff2744496952bda.zip |
Make libpq thread-safe with configure --with-threads option.
Lee Kindness
Diffstat (limited to 'src/interfaces/libpq/win32.c')
-rw-r--r-- | src/interfaces/libpq/win32.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c index 17fe9ca93ec..36c4230e747 100644 --- a/src/interfaces/libpq/win32.c +++ b/src/interfaces/libpq/win32.c @@ -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; } |