@@ -79,9 +79,8 @@ typedef struct BackgroundWorker
79
79
int bgw_flags;
80
80
BgWorkerStartTime bgw_start_time;
81
81
int bgw_restart_time; /* in seconds, or BGW_NEVER_RESTART */
82
- bgworker_main_type bgw_main;
83
- char bgw_library_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
84
- char bgw_function_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
82
+ char bgw_library_name[BGW_MAXLEN];
83
+ char bgw_function_name[BGW_MAXLEN];
85
84
Datum bgw_main_arg;
86
85
char bgw_extra[BGW_EXTRALEN];
87
86
int bgw_notify_pid;
@@ -98,9 +97,8 @@ typedef struct BackgroundWorker
98
97
int bgw_flags;
99
98
BgWorkerStartTime bgw_start_time;
100
99
int bgw_restart_time; /* in seconds, or BGW_NEVER_RESTART */
101
- bgworker_main_type bgw_main;
102
- char bgw_library_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
103
- char bgw_function_name[BGW_MAXLEN]; /* only if bgw_main is NULL */
100
+ char bgw_library_name[BGW_MAXLEN];
101
+ char bgw_function_name[BGW_MAXLEN];
104
102
Datum bgw_main_arg;
105
103
char bgw_extra[BGW_EXTRALEN];
106
104
int bgw_notify_pid;
@@ -218,37 +216,20 @@ ____________________________________________________________________________-->
218
216
<structfield>bgw_restart_time</structfield>是在崩溃情况下<command>postgres</command>启动进程之前等待的时间间隔,以秒计。它可以是任何正值,或者<literal>BGW_NEVER_RESTART</literal>,表示在出现崩溃后不重启进程。
219
217
</para>
220
218
221
- <!--==========================orignal english content==========================
222
- <para>
223
- <structfield>bgw_main</structfield> is a pointer to the function to run when
224
- the process is started. This field can only safely be used to launch
225
- functions within the core server, because shared libraries may be loaded
226
- at different starting addresses in different backend processes. This will
227
- happen on all platforms when the library is loaded using any mechanism
228
- other than <xref linkend="guc-shared-preload-libraries">. Even when that
229
- mechanism is used, address space layout variations will still occur on
230
- Windows, and when <literal>EXEC_BACKEND</> is used. Therefore, most users
231
- of this API should set this field to NULL. If it is non-NULL, it takes
232
- precedence over <structfield>bgw_library_name</> and
233
- <structfield>bgw_function_name</>.
234
- </para>
235
- ____________________________________________________________________________-->
236
- <para>
237
- <structfield>bgw_main</structfield>是进程被启动后要运行的函数指针。这个域只有在核心服务器中被用来执行函数时才是安全的,因为共享库在不同的后端进程中可能被载入到不同的起始地址。当使用除<xref linkend="guc-shared-preload-libraries">之外的任何机制载入共享库时,这种情况会在所有的平台上发生。即便是使用<xref linkend="guc-shared-preload-libraries">机制,在 Windows 上使用了<literal>EXEC_BACKEND</>的情况下,地址空间布局变化也仍然会发生。因此,这个 API 的大部分使用者应该把这个域设置为 NULL。如果这个域为非 NULL,它会优先于<structfield>bgw_library_name</>和<structfield>bgw_function_name</>。
238
- </para>
239
-
240
219
<!--==========================orignal english content==========================
241
220
<para>
242
221
<structfield>bgw_library_name</structfield> is the name of a library in
243
222
which the initial entry point for the background worker should be sought.
244
223
The named library will be dynamically loaded by the worker process and
245
224
<structfield>bgw_function_name</structfield> will be used to identify the
246
- function to be called. If loading a function from the core code,
247
- <structfield>bgw_main</> should be set instead .
225
+ function to be called. If loading a function from the core code, this must
226
+ be set to "postgres" .
248
227
</para>
249
228
____________________________________________________________________________-->
250
229
<para>
251
- <structfield>bgw_library_name</structfield>是应该在其中定位后台工作者初始入口点的库名称。所指的库将被工作者进程动态载入并且<structfield>bgw_function_name</structfield>将被用来标识要调用的函数。如果从核心代码载入一个函数,应该设置<structfield>bgw_main</>。
230
+ <structfield>bgw_library_name</structfield>是应该在其中定位后台工作者初始入口点的库名称。
231
+ 所指的库将被工作者进程动态载入并且<structfield>bgw_function_name</structfield>将被用来标识要调用的函数。
232
+ 如果从核心代码载入一个函数,则必须设置为"postgres"。
252
233
</para>
253
234
254
235
<!--==========================orignal english content==========================
@@ -265,20 +246,17 @@ ____________________________________________________________________________-->
265
246
<!--==========================orignal english content==========================
266
247
<para>
267
248
<structfield>bgw_main_arg</structfield> is the <type>Datum</> argument
268
- to the background worker main function. Regardless of whether that
269
- function is specified via <structfield>bgw_main</> or via the combination
270
- of <function>bgw_library_name</> and <function>bgw_function_name</>,
271
- this main function should take a single argument of type <type>Datum</>
272
- and return <type>void</>. <structfield>bgw_main_arg</structfield> will be
273
- passed as the argument. In addition, the global variable
274
- <literal>MyBgworkerEntry</literal>
249
+ to the background worker main function. This main function should take a
250
+ single argument of type <type>Datum</> and return <type>void</>.
251
+ <structfield>bgw_main_arg</structfield> will be passed as the argument.
252
+ In addition, the global variable <literal>MyBgworkerEntry</literal>
275
253
points to a copy of the <structname>BackgroundWorker</structname> structure
276
254
passed at registration time; the worker may find it helpful to examine
277
255
this structure.
278
256
</para>
279
257
____________________________________________________________________________-->
280
258
<para>
281
- <structfield>bgw_main_arg</structfield>是后台工作者主函数的<type>Datum</>参数。不管是通过<structfield>bgw_main</>还是通过<function>bgw_library_name</>和<function>bgw_function_name</>的组合指定这个函数, 这个主函数应该有一个单一的<type>Datum</>类型的参数,并且返回<type>void</>。<structfield>bgw_main_arg</structfield>将被作为参数传递。此外,全局变量<literal>MyBgworkerEntry</literal>指向注册时传入的<structname>BackgroundWorker</structname>结构的一份拷贝,工作者会发现检查这个结构会很有用。
259
+ <structfield>bgw_main_arg</structfield>是后台工作者主函数的<type>Datum</>参数。这个主函数应该有一个单一的<type>Datum</>类型的参数,并且返回<type>void</>。<structfield>bgw_main_arg</structfield>将被作为参数传递。此外,全局变量<literal>MyBgworkerEntry</literal>指向注册时传入的<structname>BackgroundWorker</structname>结构的一份拷贝,工作者会发现检查这个结构会很有用。
282
260
</para>
283
261
284
262
<!--==========================orignal english content==========================
@@ -348,15 +326,15 @@ ____________________________________________________________________________-->
348
326
<!--==========================orignal english content==========================
349
327
<para>
350
328
Signals are initially blocked when control reaches the
351
- <structfield>bgw_main</> function, and must be unblocked by it; this is to
329
+ background worker's main function, and must be unblocked by it; this is to
352
330
allow the process to customize its signal handlers, if necessary.
353
331
Signals can be unblocked in the new process by calling
354
332
<function>BackgroundWorkerUnblockSignals</> and blocked by calling
355
333
<function>BackgroundWorkerBlockSignals</>.
356
334
</para>
357
335
____________________________________________________________________________-->
358
336
<para>
359
- 当控制到达<structfield>bgw_main</>函数时 ,信号初始会被阻塞,并且必须被它解除阻塞。这是为了允许进程自定义它的信号处理器。在新进程中可以通过调用<function>BackgroundWorkerUnblockSignals</>来解除对信号的阻塞,还可以通过调用<function>BackgroundWorkerBlockSignals</>来阻塞信号。
337
+ 当控制到达后台进程的主函数时 ,信号初始会被阻塞,并且必须被它解除阻塞。这是为了允许进程自定义它的信号处理器。在新进程中可以通过调用<function>BackgroundWorkerUnblockSignals</>来解除对信号的阻塞,还可以通过调用<function>BackgroundWorkerBlockSignals</>来阻塞信号。
360
338
</para>
361
339
362
340
<!--==========================orignal english content==========================
0 commit comments