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

Commitf72790b

Browse files
committed
Fix min_dynamic_shared_memory on Windows.
When min_dynamic_shared_memory is set above 0, we try to find space in apre-allocated region of the main shared memory area instead of callingdsm_impl_XXX() routines to allocate more. The dsm_pin_segment() anddsm_unpin_segment() routines had a bug: they called dsm_impl_XXX()routines even for main region segments. Nobody noticed before nowbecause those routines do nothing on Unix, but on Windows they'd failwhile attempting to duplicate an invalid Windows HANDLE. Add themissing gating.Back-patch to 14, where commit84b1c63 added this feature. Fixespgsql-bugs bug #18165.Reported-by: Maxime Boyer <maxime.boyer@cra-arc.gc.ca>Tested-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/18165-bf4f525cea6e51de%40postgresql.org
1 parent5463319 commitf72790b

File tree

1 file changed

+6
-4
lines changed
  • src/backend/storage/ipc

1 file changed

+6
-4
lines changed

‎src/backend/storage/ipc/dsm.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ dsm_unpin_mapping(dsm_segment *seg)
928928
void
929929
dsm_pin_segment(dsm_segment*seg)
930930
{
931-
void*handle;
931+
void*handle=NULL;
932932

933933
/*
934934
* Bump reference count for this segment in shared memory. This will
@@ -939,7 +939,8 @@ dsm_pin_segment(dsm_segment *seg)
939939
LWLockAcquire(DynamicSharedMemoryControlLock,LW_EXCLUSIVE);
940940
if (dsm_control->item[seg->control_slot].pinned)
941941
elog(ERROR,"cannot pin a segment that is already pinned");
942-
dsm_impl_pin_segment(seg->handle,seg->impl_private,&handle);
942+
if (!is_main_region_dsm_handle(seg->handle))
943+
dsm_impl_pin_segment(seg->handle,seg->impl_private,&handle);
943944
dsm_control->item[seg->control_slot].pinned= true;
944945
dsm_control->item[seg->control_slot].refcnt++;
945946
dsm_control->item[seg->control_slot].impl_private_pm_handle=handle;
@@ -996,8 +997,9 @@ dsm_unpin_segment(dsm_handle handle)
996997
* releasing the lock, because impl_private_pm_handle may get modified by
997998
* dsm_impl_unpin_segment.
998999
*/
999-
dsm_impl_unpin_segment(handle,
1000-
&dsm_control->item[control_slot].impl_private_pm_handle);
1000+
if (!is_main_region_dsm_handle(handle))
1001+
dsm_impl_unpin_segment(handle,
1002+
&dsm_control->item[control_slot].impl_private_pm_handle);
10011003

10021004
/* Note that 1 means no references (0 means unused slot). */
10031005
if (--dsm_control->item[control_slot].refcnt==1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp