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

Commite012423

Browse files
committed
Fix logic bug in dsm_attach().
The previous coding would potentially cause attaching to segment A tofail if segment B was at the same time in the process of going away.Andres Freund, with a comment tweak by me
1 parent4335c95 commite012423

File tree

1 file changed

+8
-7
lines changed
  • src/backend/storage/ipc

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ dsm_attach(dsm_handle h)
566566
if (dsm_control->item[i].refcnt==0)
567567
continue;
568568

569+
/* If the handle doesn't match, it's not the slot we want. */
570+
if (dsm_control->item[i].handle!=seg->handle)
571+
continue;
572+
569573
/*
570574
* If the reference count is 1, the slot is still in use, but the
571575
* segment is in the process of going away. Treat that as if we
@@ -574,13 +578,10 @@ dsm_attach(dsm_handle h)
574578
if (dsm_control->item[i].refcnt==1)
575579
break;
576580

577-
/* Otherwise, if the descriptor matches, we've found a match. */
578-
if (dsm_control->item[i].handle==seg->handle)
579-
{
580-
dsm_control->item[i].refcnt++;
581-
seg->control_slot=i;
582-
break;
583-
}
581+
/* Otherwise we've found a match. */
582+
dsm_control->item[i].refcnt++;
583+
seg->control_slot=i;
584+
break;
584585
}
585586
LWLockRelease(DynamicSharedMemoryControlLock);
586587

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp