1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Treat any negative ws_file as closed in xlogreader.c

The segment_close() callback is required to set ws_file to a negative
value after closing a WAL segment, as documented in xlogreader.h.
XLogReaderFree() only treated -1 as closed, so it could call
segment_close() again if another negative value was used.

This should not be an issue in practice, but all the other code paths in
the tree use 0 as comparison base when dealing with ws_file, except for
the line updated here.  Let's be consistent, at least.

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/asNr203eue0R4zpZ@bdtpg
This commit is contained in:
Michael Paquier
2026-10-09 13:59:55 +09:00
parent 1b5dd3a24a
commit 412848dac3

View File

@@ -175,7 +175,7 @@ XLogReaderFree(XLogReaderState *state)
&state->reset_cb); &state->reset_cb);
#endif #endif
if (state->seg.ws_file != -1) if (state->seg.ws_file >= 0)
state->routine.segment_close(state); state->routine.segment_close(state);
if (state->decode_buffer && state->free_decode_buffer) if (state->decode_buffer && state->free_decode_buffer)