Skip to content

Commit a6aea86

Browse files
committed
Fix deadlock: properly unset loggin_in_progress
1 parent b1b1b14 commit a6aea86

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/utils/logger.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ exit_if_necessary(int elevel)
132132
interrupted = true;
133133

134134
if (loggin_in_progress)
135+
{
136+
loggin_in_progress = false;
135137
pthread_mutex_unlock(&log_file_mutex);
138+
}
136139

137140
/* If this is not the main thread then don't call exit() */
138141
#ifdef WIN32
@@ -171,11 +174,8 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
171174
/*
172175
* There is no need to lock if this is elog() from upper elog().
173176
*/
174-
if (!loggin_in_progress)
175-
{
176-
pthread_mutex_lock(&log_file_mutex);
177-
loggin_in_progress = true;
178-
}
177+
pthread_mutex_lock(&log_file_mutex);
178+
loggin_in_progress = true;
179179

180180
/* We need copy args only if we need write to error log file */
181181
if (write_to_error_log)
@@ -255,11 +255,8 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
255255

256256
exit_if_necessary(elevel);
257257

258-
if (loggin_in_progress)
259-
{
260-
pthread_mutex_unlock(&log_file_mutex);
261-
loggin_in_progress = false;
262-
}
258+
loggin_in_progress = false;
259+
pthread_mutex_unlock(&log_file_mutex);
263260
}
264261

265262
/*

0 commit comments

Comments
 (0)