Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
2de9a463
Commit
2de9a463
authored
15 years ago
by
Magnus Hagander
Browse files
Options
Downloads
Patches
Plain Diff
Support 64-bit shared memory when building on 64-bit Windows.
Tsutomu Yamada
parent
13c5fdb5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/backend/port/win32_shmem.c
+20
-11
20 additions, 11 deletions
src/backend/port/win32_shmem.c
src/include/storage/pg_shmem.h
+5
-1
5 additions, 1 deletion
src/include/storage/pg_shmem.h
with
25 additions
and
12 deletions
src/backend/port/win32_shmem.c
+
20
−
11
View file @
2de9a463
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.1
2
20
09/07/24 20
:1
2
:4
2
mha Exp $
* $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.1
3
20
10/01/02 12
:1
8
:4
5
mha Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -16,7 +16,7 @@
#include
"storage/ipc.h"
#include
"storage/pg_shmem.h"
unsigned
long
UsedShmemSegID
=
0
;
HANDLE
UsedShmemSegID
=
0
;
void
*
UsedShmemSegAddr
=
NULL
;
static
Size
UsedShmemSegSize
=
0
;
...
...
@@ -125,6 +125,8 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
hmap2
;
char
*
szShareMem
;
int
i
;
DWORD
size_high
;
DWORD
size_low
;
/* Room for a header? */
Assert
(
size
>
MAXALIGN
(
sizeof
(
PGShmemHeader
)));
...
...
@@ -133,6 +135,13 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
UsedShmemSegAddr
=
NULL
;
#ifdef _WIN64
size_high
=
size
>>
32
;
#else
size_high
=
0
;
#endif
size_low
=
(
DWORD
)
size
;
/*
* When recycling a shared memory segment, it may take a short while
* before it gets dropped from the global namespace. So re-try after
...
...
@@ -147,11 +156,11 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
*/
SetLastError
(
0
);
hmap
=
CreateFileMapping
(
(
HANDLE
)
0xFFFFFFFF
,
/* Use the pagefile */
hmap
=
CreateFileMapping
(
INVALID_HANDLE_VALUE
,
/* Use the pagefile */
NULL
,
/* Default security attrs */
PAGE_READWRITE
,
/* Memory is Read/Write */
0L
,
/* Size Upper 32 Bits */
(
DWORD
)
size
,
/* Size Lower 32 bits */
size_high
,
/* Size Upper 32 Bits */
size
_low
,
/* Size Lower 32 bits */
szShareMem
);
if
(
!
hmap
)
...
...
@@ -203,7 +212,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
/* Register on-exit routine to delete the new segment */
on_shmem_exit
(
pgwin32_SharedMemoryDelete
,
Int32
GetDatum
(
(
unsigned
long
)
hmap2
));
on_shmem_exit
(
pgwin32_SharedMemoryDelete
,
Pointer
GetDatum
(
hmap2
));
/*
* Get a pointer to the new shared memory segment. Map the whole segment
...
...
@@ -235,7 +244,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
/* Save info for possible future use */
UsedShmemSegAddr
=
memAddress
;
UsedShmemSegSize
=
size
;
UsedShmemSegID
=
(
unsigned
long
)
hmap2
;
UsedShmemSegID
=
hmap2
;
return
hdr
;
}
...
...
@@ -266,10 +275,10 @@ PGSharedMemoryReAttach(void)
elog
(
FATAL
,
"failed to release reserved memory region (addr=%p): %lu"
,
UsedShmemSegAddr
,
GetLastError
());
hdr
=
(
PGShmemHeader
*
)
MapViewOfFileEx
(
(
HANDLE
)
UsedShmemSegID
,
FILE_MAP_READ
|
FILE_MAP_WRITE
,
0
,
0
,
0
,
UsedShmemSegAddr
);
hdr
=
(
PGShmemHeader
*
)
MapViewOfFileEx
(
UsedShmemSegID
,
FILE_MAP_READ
|
FILE_MAP_WRITE
,
0
,
0
,
0
,
UsedShmemSegAddr
);
if
(
!
hdr
)
elog
(
FATAL
,
"could not reattach to shared memory (key=%
d
, addr=%p): %lu"
,
(
int
)
UsedShmemSegID
,
UsedShmemSegAddr
,
GetLastError
());
elog
(
FATAL
,
"could not reattach to shared memory (key=%
p
, addr=%p): %lu"
,
UsedShmemSegID
,
UsedShmemSegAddr
,
GetLastError
());
if
(
hdr
!=
origUsedShmemSegAddr
)
elog
(
FATAL
,
"reattaching to shared memory returned unexpected address (got %p, expected %p)"
,
hdr
,
origUsedShmemSegAddr
);
...
...
@@ -308,7 +317,7 @@ static void
pgwin32_SharedMemoryDelete
(
int
status
,
Datum
shmId
)
{
PGSharedMemoryDetach
();
if
(
!
CloseHandle
(
(
HANDLE
)
DatumGet
Int32
(
shmId
)))
if
(
!
CloseHandle
(
DatumGet
Pointer
(
shmId
)))
elog
(
LOG
,
"could not close handle to shared memory: %lu"
,
GetLastError
());
}
...
...
This diff is collapsed.
Click to expand it.
src/include/storage/pg_shmem.h
+
5
−
1
View file @
2de9a463
...
...
@@ -17,7 +17,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.2
5
200
9
/01/0
1
1
7:24:01 momjian
Exp $
* $PostgreSQL: pgsql/src/include/storage/pg_shmem.h,v 1.2
6
20
1
0/01/0
2
1
2:18:45 mha
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -40,7 +40,11 @@ typedef struct PGShmemHeader /* standard header for all Postgres shmem */
#ifdef EXEC_BACKEND
#ifndef WIN32
extern
unsigned
long
UsedShmemSegID
;
#else
extern
HANDLE
UsedShmemSegID
;
#endif
extern
void
*
UsedShmemSegAddr
;
extern
void
PGSharedMemoryReAttach
(
void
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment