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

Commit344d0ca

Browse files
committed
Use snprintf instead of wsprintf, and use getenv("APPDATA") instead of
SHGetFolderPath.This removes the direct dependency on shell32.dll and user32.dll, whicheats a lot of "desktop heap" for each backend that's started. Thedesktop heap is a very limited resource, causing backends to nolonger start once it's been exhausted.We still have indirect depdendencies on user32.dll through third partylibraries, but those can't easily be removed.Dave Page
1 parent12f25e7 commit344d0ca

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

‎src/backend/port/win32/signal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.18 2007/01/05 22:19:35 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/signal.c,v 1.19 2007/10/23 17:58:01 mha Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -178,7 +178,7 @@ pgwin32_create_signal_listener(pid_t pid)
178178
charpipename[128];
179179
HANDLEpipe;
180180

181-
wsprintf(pipename,"\\\\.\\pipe\\pgsignal_%d", (int)pid);
181+
snprintf(pipename,sizeof(pipename),"\\\\.\\pipe\\pgsignal_%u", (int)pid);
182182

183183
pipe=CreateNamedPipe(pipename,PIPE_ACCESS_DUPLEX,
184184
PIPE_TYPE_MESSAGE |PIPE_READMODE_MESSAGE |PIPE_WAIT,
@@ -251,7 +251,7 @@ pg_signal_thread(LPVOID param)
251251
charpipename[128];
252252
HANDLEpipe=pgwin32_initial_signal_pipe;
253253

254-
wsprintf(pipename,"\\\\.\\pipe\\pgsignal_%d",GetCurrentProcessId());
254+
snprintf(pipename,sizeof(pipename),"\\\\.\\pipe\\pgsignal_%u",GetCurrentProcessId());
255255

256256
for (;;)
257257
{

‎src/port/kill.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*signals that the backend can recognize.
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/port/kill.c,v 1.8 2007/01/05 22:20:02 momjian Exp $
12+
* $PostgreSQL: pgsql/src/port/kill.c,v 1.9 2007/10/23 17:58:01 mha Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -38,7 +38,7 @@ pgkill(int pid, int sig)
3838
errno=EINVAL;
3939
return-1;
4040
}
41-
wsprintf(pipename,"\\\\.\\pipe\\pgsignal_%i",pid);
41+
snprintf(pipename,sizeof(pipename),"\\\\.\\pipe\\pgsignal_%u",pid);
4242
if (!CallNamedPipe(pipename,&sigData,1,&sigRet,1,&bytes,1000))
4343
{
4444
if (GetLastError()==ERROR_FILE_NOT_FOUND)

‎src/port/path.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.71 2007/01/05 22:20:02 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.72 2007/10/23 17:58:01 mha Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -628,10 +628,14 @@ get_home_path(char *ret_path)
628628
strlcpy(ret_path,pwd->pw_dir,MAXPGPATH);
629629
return true;
630630
#else
631-
chartmppath[MAX_PATH];
632-
633-
ZeroMemory(tmppath,sizeof(tmppath));
634-
if (SHGetFolderPath(NULL,CSIDL_APPDATA,NULL,0,tmppath)!=S_OK)
631+
char*tmppath;
632+
633+
/*
634+
* Note: We use getenv here because the more modern SHGetSpecialFolderPath()
635+
* will force us to link with shell32.lib which eats valuable desktop heap.
636+
*/
637+
tmppath=getenv("APPDATA");
638+
if (!tmppath)
635639
return false;
636640
snprintf(ret_path,MAXPGPATH,"%s/postgresql",tmppath);
637641
return true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp