Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3312b8e

Browse files
committed
Load netmsg.dll locally in winsock_strerror, to avoid actual and
potential problems discussed in pgsql-interfaces.
1 parent9d596e0 commit3312b8e

File tree

3 files changed

+42
-29
lines changed

3 files changed

+42
-29
lines changed

‎src/interfaces/libpq/fe-misc.c

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
*
2727
* IDENTIFICATION
28-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.63 2001/11/27 18:21:51 tgl Exp $
28+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.64 2001/11/28 19:40:29 tgl Exp $
2929
*
3030
*-------------------------------------------------------------------------
3131
*/
@@ -37,6 +37,8 @@
3737
#include<time.h>
3838

3939
#ifdefWIN32
40+
#defineWIN32_LEAN_AND_MEAN
41+
#include<windows.h>
4042
#include"win32.h"
4143
#else
4244
#include<unistd.h>
@@ -858,41 +860,59 @@ libpq_gettext(const char *msgid)
858860
* If you can verify this working on win9x or have a solution, let us know, ok?
859861
*/
860862
constchar*
861-
winsock_strerror(DWORDeno)
863+
winsock_strerror(inteno)
862864
{
863-
#defineWSSE_MAXLEN (sizeof(winsock_strerror_buf)-1-12)/* 12 == "(0x00000000)" */
865+
staticcharerr_buf[512];
866+
#defineWSSE_MAXLEN (sizeof(err_buf)-1-13)/* 13 == " (0x00000000)" */
867+
HINSTANCEnetmsgModule;
864868
intlength;
865869

866870
/* First try the "system table", this works on Win2k pro */
867871

868872
if (FormatMessage(
869-
FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM,
870-
0,eno,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
871-
winsock_strerror_buf,WSSE_MAXLEN,NULL
872-
))
873+
FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM,
874+
0,
875+
eno,
876+
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
877+
err_buf,
878+
WSSE_MAXLEN,
879+
NULL))
873880
gotoWSSE_GOODEXIT;
874881

875882
/* That didn't work, let's try the netmsg.dll */
876883

877-
if (netmsgModule&&
878-
FormatMessage(
879-
FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_HMODULE,
880-
0,eno,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
881-
winsock_strerror_buf,WSSE_MAXLEN,NULL
882-
))
883-
gotoWSSE_GOODEXIT;
884+
netmsgModule=LoadLibraryEx("netmsg.dll",
885+
NULL,
886+
LOAD_LIBRARY_AS_DATAFILE);
887+
888+
if (netmsgModule!=NULL)
889+
{
890+
if (FormatMessage(
891+
FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_HMODULE,
892+
netmsgModule,
893+
eno,
894+
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
895+
err_buf,
896+
WSSE_MAXLEN,
897+
NULL))
898+
{
899+
FreeLibrary(netmsgModule);
900+
gotoWSSE_GOODEXIT;
901+
}
902+
FreeLibrary(netmsgModule);
903+
}
884904

885905
/* Everything failed, just tell the user that we don't know the desc */
886906

887-
strcpy(winsock_strerror_buf,"Socket error, no description available.");
907+
strcpy(err_buf,"Socket error, no description available.");
888908

889909
WSSE_GOODEXIT:
890910

891-
length=strlen(winsock_strerror_buf);
892-
sprintf(winsock_strerror_buf+ (length<WSSE_MAXLEN ?length :WSSE_MAXLEN),
893-
"(0x%08X)",eno);
911+
length=strlen(err_buf);
912+
sprintf(err_buf+ (length<WSSE_MAXLEN ?length :WSSE_MAXLEN),
913+
"(0x%08X)",eno);
894914

895-
returnwinsock_strerror_buf;
915+
returnerr_buf;
896916
}
897917

898918
#endif

‎src/interfaces/libpq/libpqdll.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#defineWIN32_LEAN_AND_MEAN
22
#include<windows.h>
3-
#include<winsock.h>
43
#include"win32.h"
54

5+
66
BOOLWINAPI
77
DllMain(HINSTANCEhinstDLL,DWORDfdwReason,
88
LPVOIDlpReserved)
@@ -20,12 +20,8 @@ DllMain(HINSTANCE hinstDLL, DWORD fdwReason,
2020
*/
2121
return FALSE;
2222
}
23-
if (netmsgModule==NULL)
24-
netmsgModule=LoadLibraryEx("netmsg.dll",NULL,LOAD_LIBRARY_AS_DATAFILE);
2523
break;
2624
caseDLL_PROCESS_DETACH:
27-
if (netmsgModule!=NULL)
28-
FreeLibrary(netmsgModule);
2925
WSACleanup();
3026
break;
3127
}

‎src/interfaces/libpq/win32.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
#defineEINPROGRESS WSAEINPROGRESS
3232

3333
/*
34-
*Windows network messaging stuff:
34+
*support for handling Windows Socket errors
3535
*/
36-
staticHINSTANCEnetmsgModule=NULL;
37-
38-
staticcharwinsock_strerror_buf[512];
39-
constchar*winsock_strerror(DWORDeno);
36+
externconstchar*winsock_strerror(inteno);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp