Skip to content

Commit b1b1b14

Browse files
committed
Fix deadlock: unlock before pthread_exit()
1 parent f6b8264 commit b1b1b14

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/backup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,6 +2443,10 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished)
24432443
static uint32 prevtimeline = 0;
24442444
static XLogRecPtr prevpos = InvalidXLogRecPtr;
24452445

2446+
/* check for interrupt */
2447+
if (interrupted)
2448+
elog(ERROR, "Interrupted during backup");
2449+
24462450
/* we assume that we get called once at the end of each segment */
24472451
if (segment_finished)
24482452
elog(VERBOSE, _("finished segment at %X/%X (timeline %u)"),

src/utils/logger.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ exit_if_necessary(int elevel)
131131
/* Interrupt other possible routines */
132132
interrupted = true;
133133

134+
if (loggin_in_progress)
135+
pthread_mutex_unlock(&log_file_mutex);
136+
134137
/* If this is not the main thread then don't call exit() */
135138
#ifdef WIN32
136139
if (main_tid != GetCurrentThreadId())
@@ -250,13 +253,13 @@ elog_internal(int elevel, bool file_only, const char *fmt, va_list args)
250253
va_end(std_args);
251254
}
252255

256+
exit_if_necessary(elevel);
257+
253258
if (loggin_in_progress)
254259
{
255260
pthread_mutex_unlock(&log_file_mutex);
256261
loggin_in_progress = false;
257262
}
258-
259-
exit_if_necessary(elevel);
260263
}
261264

262265
/*

0 commit comments

Comments
 (0)