Skip to content

Commit 000b65f

Browse files
committed
pg_upgrade: clarify C comment about Windows thread struct pointers
Backpatch to 9.3 to keep source trees consistent.
1 parent 69b7d59 commit 000b65f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

contrib/pg_upgrade/parallel.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
130130
/* fork failed */
131131
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
132132
#else
133-
/* use first empty array element */
133+
/* empty array element are always at the end */
134134
new_arg = exec_thread_args[parallel_jobs - 1];
135135

136136
/* 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,
244244
/* fork failed */
245245
pg_log(PG_FATAL, "could not create worker process: %s\n", strerror(errno));
246246
#else
247-
/* use first empty array element */
247+
/* empty array element are always at the end */
248248
new_arg = transfer_thread_args[parallel_jobs - 1];
249249

250250
/* Can only pass one pointer into the function, so use a struct */
@@ -339,10 +339,10 @@ reap_child(bool wait_for_child)
339339
thread_handles[thread_num] = thread_handles[parallel_jobs - 1];
340340

341341
/*
342-
* We must swap the arg struct pointers because the thread we just
343-
* moved is active, and we must make sure it is not reused by the next
344-
* created thread. Instead, the new thread will use the arg struct of
345-
* the thread that just died.
342+
* Move last active thead arg struct into the now-dead slot,
343+
* and the now-dead slot to the end for reuse by the next thread.
344+
* Though the thread struct is in use by another thread, we can
345+
* safely swap the struct pointers within the array.
346346
*/
347347
tmp_args = cur_thread_args[thread_num];
348348
cur_thread_args[thread_num] = cur_thread_args[parallel_jobs - 1];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy