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

Commitcb9a0c7

Browse files
committed
Teach on_exit_reset() to discard pending cleanups for dsm.
If a postmaster child invokes fork() and then calls on_exit_reset, thatshould be sufficient to let it exit() without breaking anything, butdynamic shared memory broke that by not updating on_exit_reset() todiscard callbacks registered with dynamic shared memory segments.Per investigation of a complaint from Tom Lane.
1 parent7704944 commitcb9a0c7

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,37 @@ cancel_on_dsm_detach(dsm_segment *seg, on_dsm_detach_callback function,
979979
}
980980
}
981981

982+
/*
983+
* Discard all registered on-detach callbacks without executing them.
984+
*/
985+
void
986+
reset_on_dsm_detach(void)
987+
{
988+
dlist_iteriter;
989+
990+
dlist_foreach(iter,&dsm_segment_list)
991+
{
992+
dsm_segment*seg=dlist_container(dsm_segment,node,iter.cur);
993+
994+
/* Throw away explicit on-detach actions one by one. */
995+
while (!slist_is_empty(&seg->on_detach))
996+
{
997+
slist_node*node;
998+
dsm_segment_detach_callback*cb;
999+
1000+
node=slist_pop_head_node(&seg->on_detach);
1001+
cb=slist_container(dsm_segment_detach_callback,node,node);
1002+
pfree(cb);
1003+
}
1004+
1005+
/*
1006+
* Decrementing the reference count is a sort of implicit on-detach
1007+
* action; make sure we don't do that, either.
1008+
*/
1009+
seg->control_slot=INVALID_CONTROL_SLOT;
1010+
}
1011+
}
1012+
9821013
/*
9831014
* Create a segment descriptor.
9841015
*/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,5 @@ on_exit_reset(void)
400400
before_shmem_exit_index=0;
401401
on_shmem_exit_index=0;
402402
on_proc_exit_index=0;
403+
reset_on_dsm_detach();
403404
}

‎src/include/storage/dsm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ extern void on_dsm_detach(dsm_segment *seg,
4343
on_dsm_detach_callbackfunction,Datumarg);
4444
externvoidcancel_on_dsm_detach(dsm_segment*seg,
4545
on_dsm_detach_callbackfunction,Datumarg);
46+
externvoidreset_on_dsm_detach(void);
4647

4748
#endif/* DSM_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp