Add more critical-section calls: all code sections that hold spinlocks
Tom Lane <tgl@sss.pgh.pa.us>
Add more critical-section calls: all code sections that hold spinlocks are now critical sections, so as to ensure die() won't interrupt us while we are munging shared-memory data structures. Avoid insecure intermediate states in some code that proc_exit will call, like palloc/pfree. Rename START/END_CRIT_CODE to START/END_CRIT_SECTION, since that seems to be what people tend to call them anyway, and make them be called with () like a function call, in hopes of not confusing pg_indent. I doubt that this is sufficient to make SIGTERM safe anywhere; there's just too much code that could get invoked during proc_exit().
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/heap/heapam.c | modified | +7 −7 |
| src/backend/access/nbtree/nbtinsert.c | modified | +7 −7 |
| src/backend/access/nbtree/nbtpage.c | modified | +5 −5 |
| src/backend/access/transam/xact.c | modified | +5 −5 |
| src/backend/access/transam/xlog.c | modified | +12 −12 |
| src/backend/commands/sequence.c | modified | +5 −5 |
| src/backend/commands/vacuum.c | modified | +9 −9 |
| src/backend/storage/buffer/bufmgr.c | modified | +31 −14 |
| src/backend/storage/file/fd.c | modified | +9 −3 |
| src/backend/storage/ipc/spin.c | modified | +31 −4 |
| src/backend/storage/lmgr/proc.c | modified | +6 −23 |
| src/backend/tcop/postgres.c | modified | +3 −3 |
| src/backend/utils/cache/temprel.c | modified | +2 −3 |
| src/backend/utils/init/postinit.c | modified | +5 −4 |
| src/backend/utils/mmgr/aset.c | modified | +19 −17 |
| src/include/access/xlog.h | modified | +2 −2 |
| src/include/utils/elog.h | modified | +5 −6 |