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

Commitf7df804

Browse files
committed
Remove Windows module-list-dumping code.
This code is evidently allocating memory and thus confusing matterseven more. Let's see whether we can learn anything withjust VirtualQuery.Discussion:https://postgr.es/m/25495.1524517820@sss.pgh.pa.us
1 parentbb77900 commitf7df804

File tree

4 files changed

+10
-44
lines changed

4 files changed

+10
-44
lines changed

‎src/backend/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ libpostgres.a: postgres
7979
endif# cygwin
8080

8181
ifeq ($(PORTNAME), win32)
82-
LIBS += -lsecur32 -lpsapi
82+
LIBS += -lsecur32
8383

8484
postgres:$(OBJS)$(WIN32RES)
8585
$(CC)$(CFLAGS)$(LDFLAGS)$(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a$(call expand_subsys,$(OBJS))$(WIN32RES)$(LIBS) -o$@$(X)

‎src/backend/port/win32_shmem.c

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*/
1313
#include"postgres.h"
1414

15-
#include<psapi.h>
16-
1715
#include"miscadmin.h"
1816
#include"storage/dsm.h"
1917
#include"storage/ipc.h"
@@ -26,32 +24,6 @@ static Size UsedShmemSegSize = 0;
2624
staticboolEnableLockPagesPrivilege(intelevel);
2725
staticvoidpgwin32_SharedMemoryDelete(intstatus,DatumshmId);
2826

29-
/* Dump all modules loaded into proc */
30-
staticvoid
31-
dumpdlls(HANDLEproc)
32-
{
33-
HMODULEdll[1024];
34-
DWORDsize_used=1;
35-
inti,
36-
n;
37-
38-
if (!EnumProcessModules(proc,dll,sizeof(dll),&size_used))
39-
{
40-
elog(LOG,"EnumProcessModules failed: %lu",GetLastError());
41-
return;
42-
}
43-
n= (int) (size_used /sizeof(*dll));
44-
elog(LOG,"EnumProcessModules: %d modules in process 0x%p",n,proc);
45-
for (i=0;i<n;i++)
46-
{
47-
charname[MAXPGPATH];
48-
49-
if (!GetModuleFileNameEx(proc,dll[i],name,sizeof(name)))
50-
sprintf(name,"GetModuleFileNameEx failed: %lu",GetLastError());
51-
elog(LOG,"%d: 0x%p %s",i+1,dll[i],name);
52-
}
53-
}
54-
5527
staticconstchar*
5628
mi_type(DWORDcode)
5729
{
@@ -83,7 +55,7 @@ mi_state(DWORD code)
8355
}
8456

8557
staticvoid
86-
dumpmem(constchar*reason,HANDLEproc)
58+
dumpmem(constchar*reason)
8759
{
8860
char*addr=0;
8961
MEMORY_BASIC_INFORMATIONmi;
@@ -92,20 +64,18 @@ dumpmem(const char *reason, HANDLE proc)
9264
do
9365
{
9466
memset(&mi,0,sizeof(mi));
95-
if (!VirtualQueryEx(proc,addr,&mi,sizeof(mi)))
67+
if (!VirtualQuery(addr,&mi,sizeof(mi)))
9668
{
9769
if (GetLastError()==ERROR_INVALID_PARAMETER)
9870
break;
99-
elog(LOG,"VirtualQueryEx failed: %lu",GetLastError());
71+
elog(LOG,"VirtualQuery failed: %lu",GetLastError());
10072
break;
10173
}
10274
elog(LOG,"0x%p+0x%p %s (alloc 0x%p) %s",
10375
mi.BaseAddress, (void*)mi.RegionSize,
10476
mi_type(mi.Type),mi.AllocationBase,mi_state(mi.State));
10577
addr+=mi.RegionSize;
10678
}while (addr>0);
107-
108-
dumpdlls(proc);
10979
}
11080

11181
/*
@@ -446,7 +416,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
446416

447417
/* Log information about the segment's virtual memory use */
448418
if (VirtualQuery(memAddress,&info,sizeof(info))!=0)
449-
elog(LOG,"mapped shared memory segment at %p, requested size%zu, mapped size%zu",
419+
elog(LOG,"mapped shared memory segment at %p, requested size0x%zx, mapped size0x%zx",
450420
memAddress,size,info.RegionSize);
451421
else
452422
elog(LOG,"VirtualQuery(%p) failed: error code %lu",
@@ -476,7 +446,7 @@ PGSharedMemoryReAttach(void)
476446
Assert(UsedShmemSegAddr!=NULL);
477447
Assert(IsUnderPostmaster);
478448

479-
dumpmem("before VirtualFree",GetCurrentProcess());
449+
dumpmem("before VirtualFree");
480450

481451
/*
482452
* Release memory region reservation that was made by the postmaster
@@ -485,18 +455,20 @@ PGSharedMemoryReAttach(void)
485455
elog(FATAL,"failed to release reserved memory region (addr=%p): error code %lu",
486456
UsedShmemSegAddr,GetLastError());
487457

488-
dumpmem("after VirtualFree",GetCurrentProcess());
458+
dumpmem("after VirtualFree");
489459

490460
hdr= (PGShmemHeader*)MapViewOfFileEx(UsedShmemSegID,FILE_MAP_READ |FILE_MAP_WRITE,0,0,0,UsedShmemSegAddr);
491461
if (!hdr)
492462
{
493463
DWORDmaperr=GetLastError();
494464

495-
dumpmem("after MapViewOfFileEx",GetCurrentProcess());
465+
dumpmem("afterfailedMapViewOfFileEx");
496466

497467
elog(FATAL,"could not reattach to shared memory (key=%p, addr=%p): error code %lu",
498468
UsedShmemSegID,UsedShmemSegAddr,maperr);
499469
}
470+
else
471+
dumpmem("after MapViewOfFileEx");
500472
if (hdr!=origUsedShmemSegAddr)
501473
elog(FATAL,"reattaching to shared memory returned unexpected address (got %p, expected %p)",
502474
hdr,origUsedShmemSegAddr);
@@ -639,7 +611,5 @@ pgwin32_ReserveSharedMemoryRegion(HANDLE hChild)
639611
return false;
640612
}
641613

642-
dumpmem("after reserve",hChild);
643-
644614
return true;
645615
}

‎src/makefiles/Makefile.win32

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# src/makefiles/Makefile.win32
22

3-
override CPPFLAGS+= -DPSAPI_VERSION=1
4-
53
ifdef PGXS
64
BE_DLLLIBS= -L$(libdir) -lpostgres
75
override CPPFLAGS+= -I$(includedir_server)/port/win32

‎src/tools/msvc/Mkvcbuild.pm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,8 @@ sub mkvcbuild
174174
'repl_gram.y','syncrep_scanner.l',
175175
'syncrep_gram.y');
176176
$postgres->AddDefine('BUILDING_DLL');
177-
$postgres->AddDefine('PSAPI_VERSION=1');
178177
$postgres->AddLibrary('secur32.lib');
179178
$postgres->AddLibrary('ws2_32.lib');
180-
$postgres->AddLibrary('psapi.lib');
181179
$postgres->AddLibrary('wldap32.lib')if ($solution->{options}->{ldap});
182180
$postgres->FullExportDLL('postgres.lib');
183181

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp