aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_backup_utils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-05-27 12:02:09 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-05-27 12:02:09 -0400
commit807b45375beae6563c3833e72d91869e9b9134e5 (patch)
treec245e6fee9751684a1fb5203ba7f79cf7b70a60a /src/bin/pg_dump/pg_backup_utils.c
parentd81ecb9b204ae4aaf10b6a056447fe4ee853d195 (diff)
downloadpostgresql-807b45375beae6563c3833e72d91869e9b9134e5.tar.gz
postgresql-807b45375beae6563c3833e72d91869e9b9134e5.zip
Clean up thread management in parallel pg_dump for Windows.
Since we start the worker threads with _beginthreadex(), we should use _endthreadex() to terminate them. We got this right in the normal-exit code path, but not so much during an error exit from a worker. In addition, be sure to apply CloseHandle to the thread handle after each thread exits. It's not clear that these oversights cause any user-visible problems, since the pg_dump run is about to terminate anyway. Still, it's clearly better to follow Microsoft's API specifications than ignore them. Also a few cosmetic cleanups in WaitForTerminatingWorkers(), including being a bit less random about where to cast between uintptr_t and HANDLE, and being sure to clear the worker identity field for each dead worker (not that false matches should be possible later, but let's be careful). Original observation and patch by Armin Schöffmann, cosmetic improvements by Michael Paquier and me. (Armin's patch also included closing sockets in ShutdownWorkersHard(), but that's been dealt with already in commit df8d2d8c4.) Back-patch to 9.3 where parallel pg_dump was introduced. Discussion: <zarafa.570306bd.3418.074bf1420d8f2ba2@root.aegaeon.de>
Diffstat (limited to 'src/bin/pg_dump/pg_backup_utils.c')
-rw-r--r--src/bin/pg_dump/pg_backup_utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bin/pg_dump/pg_backup_utils.c b/src/bin/pg_dump/pg_backup_utils.c
index 5d1d87565a2..01bf5764551 100644
--- a/src/bin/pg_dump/pg_backup_utils.c
+++ b/src/bin/pg_dump/pg_backup_utils.c
@@ -149,7 +149,7 @@ exit_nicely(int code)
#ifdef WIN32
if (parallel_init_done && GetCurrentThreadId() != mainThreadId)
- ExitThread(code);
+ _endthreadex(code);
#endif
exit(code);