1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-31 12:33:33 +02:00

[Issue #274] execute atexit callbackups in correct order to avoid truncating log file

This commit is contained in:
Grigory Smolkin 2020-11-09 13:50:56 +03:00
parent 895b57f67c
commit caa98327b7

View File

@ -48,7 +48,7 @@ static char *get_log_message(const char *fmt, va_list args) pg_attribute_printf(
/* Functions to work with log files */
static void open_logfile(FILE **file, const char *filename_format);
static void release_logfile(void);
static void release_logfile(bool fatal, void *userdata);
static char *logfile_getname(const char *format, time_t timestamp);
static FILE *logfile_open(const char *filename, const char *mode);
@ -224,12 +224,7 @@ elog_internal(int elevel, bool file_only, const char *message)
if (write_to_file)
{
if (log_file == NULL)
{
if (logger_config.log_filename == NULL)
open_logfile(&log_file, LOG_FILENAME_DEFAULT);
else
open_logfile(&log_file, logger_config.log_filename);
}
open_logfile(&log_file, logger_config.log_filename ? logger_config.log_filename : LOG_FILENAME_DEFAULT);
fprintf(log_file, "%s ", strfbuf);
fprintf(log_file, "%s ", str_pid);
@ -699,7 +694,7 @@ logfile_open:
*/
if (!exit_hook_registered)
{
atexit(release_logfile);
pgut_atexit_push(release_logfile, NULL);
exit_hook_registered = true;
}
}
@ -708,7 +703,7 @@ logfile_open:
* Closes opened file.
*/
static void
release_logfile(void)
release_logfile(bool fatal, void *userdata)
{
if (log_file)
{