aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2013-07-30 09:23:31 -0400
committerBruce Momjian <bruce@momjian.us>2013-07-30 09:23:31 -0400
commit000b65fd2b9fa0880a255043f50f562b8e8287b0 (patch)
tree465ac6141e1d93dfc130bc041c0e078cbacc8a65
parent69b7d59a744134e33bbe51dab44dd4113c83b7fb (diff)
downloadpostgresql-000b65fd2b9fa0880a255043f50f562b8e8287b0.tar.gz
postgresql-000b65fd2b9fa0880a255043f50f562b8e8287b0.zip
pg_upgrade: clarify C comment about Windows thread struct pointers
Backpatch to 9.3 to keep source trees consistent.
-rw-r--r--contrib/pg_upgrade/parallel.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/contrib/pg_upgrade/parallel.c b/contrib/pg_upgrade/parallel.c
index 38ded518329..f00bb7181a7 100644
--- a/contrib/pg_upgrade/parallel.c
+++ b/contrib/pg_upgrade/parallel.c
@@ -130,7 +130,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
/* fork failed */
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
#else
- /* use first empty array element */
+ /* empty array element are always at the end */
new_arg = exec_thread_args[parallel_jobs - 1];
/* Can only pass one pointer into the function, so use a struct */
@@ -244,7 +244,7 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
/* fork failed */
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
#else
- /* use first empty array element */
+ /* empty array element are always at the end */
new_arg = transfer_thread_args[parallel_jobs - 1];
/* Can only pass one pointer into the function, so use a struct */
@@ -339,10 +339,10 @@ reap_child(bool wait_for_child)
thread_handles[thread_num] = thread_handles[parallel_jobs - 1];
/*
- * We must swap the arg struct pointers because the thread we just
- * moved is active, and we must make sure it is not reused by the next
- * created thread. Instead, the new thread will use the arg struct of
- * the thread that just died.
+ * Move last active thead arg struct into the now-dead slot,
+ * and the now-dead slot to the end for reuse by the next thread.
+ * Though the thread struct is in use by another thread, we can
+ * safely swap the struct pointers within the array.
*/
tmp_args = cur_thread_args[thread_num];
cur_thread_args[thread_num] = cur_thread_args[parallel_jobs - 1];