Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4c6ccc

Browse files
committed
pg_upgrade: fix initialization of thread argument
Reorder initialization of thread argument marker to it happens beforereap_child() is called.Backpatch to 9.3.
1 parent8312832 commite4c6ccc

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

‎contrib/pg_upgrade/parallel.c

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
8787
{
8888
/* parallel */
8989
#ifdefWIN32
90+
if (thread_handles==NULL)
91+
thread_handles=pg_malloc(user_opts.jobs*sizeof(HANDLE));
92+
93+
if (exec_thread_args==NULL)
94+
{
95+
inti;
96+
97+
exec_thread_args=pg_malloc(user_opts.jobs*sizeof(exec_thread_arg*));
98+
99+
/*
100+
* For safety and performance, we keep the args allocated during
101+
* the entire life of the process, and we don't free the args in a
102+
* thread different from the one that allocated it.
103+
*/
104+
for (i=0;i<user_opts.jobs;i++)
105+
exec_thread_args[i]=pg_malloc0(sizeof(exec_thread_arg));
106+
}
107+
90108
cur_thread_args= (void**)exec_thread_args;
91109
#endif
92110
/* harvest any dead children */
@@ -112,24 +130,6 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
112130
/* fork failed */
113131
pg_log(PG_FATAL,"could not create worker process: %s\n",strerror(errno));
114132
#else
115-
if (thread_handles==NULL)
116-
thread_handles=pg_malloc(user_opts.jobs*sizeof(HANDLE));
117-
118-
if (exec_thread_args==NULL)
119-
{
120-
inti;
121-
122-
exec_thread_args=pg_malloc(user_opts.jobs*sizeof(exec_thread_arg*));
123-
124-
/*
125-
* For safety and performance, we keep the args allocated during
126-
* the entire life of the process, and we don't free the args in a
127-
* thread different from the one that allocated it.
128-
*/
129-
for (i=0;i<user_opts.jobs;i++)
130-
exec_thread_args[i]=pg_malloc0(sizeof(exec_thread_arg));
131-
}
132-
133133
/* use first empty array element */
134134
new_arg=exec_thread_args[parallel_jobs-1];
135135

@@ -196,6 +196,24 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
196196
{
197197
/* parallel */
198198
#ifdefWIN32
199+
if (thread_handles==NULL)
200+
thread_handles=pg_malloc(user_opts.jobs*sizeof(HANDLE));
201+
202+
if (transfer_thread_args==NULL)
203+
{
204+
inti;
205+
206+
transfer_thread_args=pg_malloc(user_opts.jobs*sizeof(transfer_thread_arg*));
207+
208+
/*
209+
* For safety and performance, we keep the args allocated during
210+
* the entire life of the process, and we don't free the args in a
211+
* thread different from the one that allocated it.
212+
*/
213+
for (i=0;i<user_opts.jobs;i++)
214+
transfer_thread_args[i]=pg_malloc0(sizeof(transfer_thread_arg));
215+
}
216+
199217
cur_thread_args= (void**)transfer_thread_args;
200218
#endif
201219
/* harvest any dead children */
@@ -226,24 +244,6 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
226244
/* fork failed */
227245
pg_log(PG_FATAL,"could not create worker process: %s\n",strerror(errno));
228246
#else
229-
if (thread_handles==NULL)
230-
thread_handles=pg_malloc(user_opts.jobs*sizeof(HANDLE));
231-
232-
if (transfer_thread_args==NULL)
233-
{
234-
inti;
235-
236-
transfer_thread_args=pg_malloc(user_opts.jobs*sizeof(transfer_thread_arg*));
237-
238-
/*
239-
* For safety and performance, we keep the args allocated during
240-
* the entire life of the process, and we don't free the args in a
241-
* thread different from the one that allocated it.
242-
*/
243-
for (i=0;i<user_opts.jobs;i++)
244-
transfer_thread_args[i]=pg_malloc0(sizeof(transfer_thread_arg));
245-
}
246-
247247
/* use first empty array element */
248248
new_arg=transfer_thread_args[parallel_jobs-1];
249249

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp