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

Commit4ab7769

Browse files
author
Amit Kapila
committed
Fix the SharedFileSetUnregister API.
Commit808e13b introduced a few APIs to extend the existing Buffileinterface. In SharedFileSetDeleteOnProcExit, it tries to delete the listelement while traversing the list with 'foreach' construct which makes thebehavior of list traversal unpredictable.Author: Amit KapilaReviewed-by: Dilip KumarTested-by: Dilip Kumar and Neha SharmaDiscussion:https://postgr.es/m/CAA4eK1JhLatVcQ2OvwA_3s0ih6Hx9+kZbq107cXVsSWWukH7vA@mail.gmail.com
1 parentab3c6d4 commit4ab7769

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎src/backend/storage/file/sharedfileset.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,16 @@ SharedFileSetOnDetach(dsm_segment *segment, Datum datum)
266266
staticvoid
267267
SharedFileSetDeleteOnProcExit(intstatus,Datumarg)
268268
{
269-
ListCell*l;
270-
271-
/* Loop over all the pending shared fileset entry */
272-
foreach(l,filesetlist)
269+
/*
270+
* Remove all the pending shared fileset entries. We don't use foreach() here
271+
* because SharedFileSetDeleteAll will remove the current element in
272+
* filesetlist. Though we have used foreach_delete_current() to remove the
273+
* element from filesetlist it could only fix up the state of one of the
274+
* loops, see SharedFileSetUnregister.
275+
*/
276+
while (list_length(filesetlist)>0)
273277
{
274-
SharedFileSet*fileset= (SharedFileSet*)lfirst(l);
278+
SharedFileSet*fileset= (SharedFileSet*)linitial(filesetlist);
275279

276280
SharedFileSetDeleteAll(fileset);
277281
}
@@ -301,7 +305,7 @@ SharedFileSetUnregister(SharedFileSet *input_fileset)
301305
/* Remove the entry from the list */
302306
if (input_fileset==fileset)
303307
{
304-
filesetlist=list_delete_cell(filesetlist,l);
308+
filesetlist=foreach_delete_current(filesetlist,l);
305309
return;
306310
}
307311
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp