/* *Forsafetyandperformance,wekeeptheargsallocatedduring *theentirelifeoftheprocess,andwedon'tfreetheargsina *threaddifferentfromtheonethatallocatedit.
*/ for (i = 0; i < user_opts.jobs; i++)
exec_thread_args[i] = pg_malloc0(sizeof(exec_thread_arg));
}
cur_thread_args = (void **) exec_thread_args; #endif /* harvest any dead children */ while (reap_child(false) == true)
;
/* must we wait for a dead child? */ if (parallel_jobs >= user_opts.jobs)
reap_child(true);
/* set this before we start the job */
parallel_jobs++;
/* Ensure stdio state is quiesced before forking */
fflush(NULL);
#ifndef WIN32
child = fork(); if (child == 0) /* use _exit to skip atexit() functions */
_exit(!exec_prog(log_file, opt_log_file, true, true, "%s", cmd)); elseif (child < 0) /* fork failed */
pg_fatal("could not create worker process: %m"); #else /* 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 */
pg_free(new_arg->log_file);
new_arg->log_file = pg_strdup(log_file);
pg_free(new_arg->opt_log_file);
new_arg->opt_log_file = opt_log_file ? pg_strdup(opt_log_file) : NULL;
pg_free(new_arg->cmd);
new_arg->cmd = pg_strdup(cmd);
/* *Forsafetyandperformance,wekeeptheargsallocatedduring *theentirelifeoftheprocess,andwedon'tfreetheargsina *threaddifferentfromtheonethatallocatedit.
*/ for (i = 0; i < user_opts.jobs; i++)
transfer_thread_args[i] = pg_malloc0(sizeof(transfer_thread_arg));
}
cur_thread_args = (void **) transfer_thread_args; #endif /* harvest any dead children */ while (reap_child(false) == true)
;
/* must we wait for a dead child? */ if (parallel_jobs >= user_opts.jobs)
reap_child(true);
/* set this before we start the job */
parallel_jobs++;
/* Ensure stdio state is quiesced before forking */
fflush(NULL);
#ifndef WIN32
child = fork(); if (child == 0)
{
transfer_all_new_dbs(old_db_arr, new_db_arr, old_pgdata, new_pgdata,
old_tablespace); /* if we take another exit path, it will be non-zero */ /* use _exit to skip atexit() functions */
_exit(0);
} elseif (child < 0) /* fork failed */
pg_fatal("could not create worker process: %m"); #else /* 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 */
new_arg->old_db_arr = old_db_arr;
new_arg->new_db_arr = new_db_arr;
pg_free(new_arg->old_pgdata);
new_arg->old_pgdata = pg_strdup(old_pgdata);
pg_free(new_arg->new_pgdata);
new_arg->new_pgdata = pg_strdup(new_pgdata);
pg_free(new_arg->old_tablespace);
new_arg->old_tablespace = old_tablespace ? pg_strdup(old_tablespace) : NULL;
/* *collectstatusfromacompletedworkerchild
*/ bool
reap_child(bool wait_for_child)
{ #ifndef WIN32 int work_status;
pid_t child; #else int thread_num;
DWORD res; #endif
if (user_opts.jobs <= 1 || parallel_jobs == 0) returnfalse;
#ifndef WIN32
child = waitpid(-1, &work_status, wait_for_child ? 0 : WNOHANG); if (child == (pid_t) -1)
pg_fatal("%s() failed: %m", "waitpid"); if (child == 0) returnfalse; /* no children, or no dead children */ if (work_status != 0)
pg_fatal("child process exited abnormally: status %d", work_status); #else /* wait for one to finish */
thread_num = WaitForMultipleObjects(parallel_jobs, thread_handles, false, wait_for_child ? INFINITE : 0);
if (thread_num == WAIT_TIMEOUT || thread_num == WAIT_FAILED) returnfalse;
/* compute thread index in active_threads */
thread_num -= WAIT_OBJECT_0;
/* get the result */
GetExitCodeThread(thread_handles[thread_num], &res); if (res != 0)
pg_fatal("child worker exited abnormally: %m");
/* dispose of handle to stop leaks */
CloseHandle(thread_handles[thread_num]);
/* Move last slot into dead child's position */ if (thread_num != parallel_jobs - 1)
{ void *tmp_args;
/* do this after job has been removed */
parallel_jobs--;
returntrue;
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.