1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

pg_dump: get rid of die_horribly

The old code was using exit_horribly or die_horribly other depending on
whether it had an ArchiveHandle on which to close the connection or not;
but there were places that were passing a NULL ArchiveHandle to
die_horribly, and other places that used exit_horribly while having an
AH available.  So there wasn't all that much consistency.

Improve the situation by keeping only one of the routines, and instead
of having to pass the AH down from the caller, arrange for it to be
present for an on_exit_nicely callback to operate on.

Author: Joachim Wieland
Some tweaks by me

Per a suggestion from Robert Haas, in the ongoing "parallel pg_dump"
saga.
This commit is contained in:
Alvaro Herrera
2012-03-20 18:38:11 -03:00
parent b251cf3193
commit 9d23a70d51
12 changed files with 411 additions and 329 deletions

View File

@ -49,6 +49,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
#ifdef WIN32
static bool parallel_init_done = false;
static DWORD tls_index;
static DWORD mainThreadId;
#endif
void
@ -59,6 +60,7 @@ init_parallel_dump_utils(void)
{
tls_index = TlsAlloc();
parallel_init_done = true;
mainThreadId = GetCurrentThreadId();
}
#endif
}
@ -1320,5 +1322,9 @@ exit_nicely(int code)
while (--on_exit_nicely_index >= 0)
(*on_exit_nicely_list[on_exit_nicely_index].function)(code,
on_exit_nicely_list[on_exit_nicely_index].arg);
#ifdef WIN32
if (parallel_init_done && GetCurrentThreadId() != mainThreadId)
ExitThread(code);
#endif
exit(code);
}