Skip to content

Commit 350b7fc

Browse files
authored
Merge pull request #6543 from garlick/no_child_watcher
libflux: drop child watchers and the FLUX_REACTOR_SIGCHLD flag
2 parents 02ad07c + 17e1b1f commit 350b7fc

32 files changed

+447
-343
lines changed

doc/Makefile.am

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ MAN3_FILES_PRIMARY = \
119119
man3/flux_msg_cmp.3 \
120120
man3/flux_msg_create.3 \
121121
man3/flux_msg_handler_addvec.3 \
122-
man3/flux_child_watcher_create.3 \
123122
man3/flux_signal_watcher_create.3 \
124123
man3/flux_stat_watcher_create.3 \
125124
man3/flux_respond.3 \
@@ -222,8 +221,6 @@ MAN3_FILES_SECONDARY = \
222221
man3/flux_msg_handler_stop.3 \
223222
man3/flux_get_handle_watcher.3 \
224223
man3/flux_msg_handler_delvec.3 \
225-
man3/flux_child_watcher_get_rpid.3 \
226-
man3/flux_child_watcher_get_rstatus.3 \
227224
man3/flux_signal_watcher_get_signum.3 \
228225
man3/flux_stat_watcher_get_rstat.3 \
229226
man3/flux_respond_raw.3 \

doc/man3/flux_child_watcher_create.rst

Lines changed: 0 additions & 81 deletions
This file was deleted.

doc/man3/flux_reactor_create.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ DESCRIPTION
2727
===========
2828

2929
:func:`flux_reactor_create` creates a :type:`flux_reactor_t` object which can
30-
be used to monitor for events on file descriptors, ZeroMQ sockets, timers, and
31-
:type:`flux_t` broker handles.
32-
33-
There is currently only one possible flag for reactor creation:
34-
35-
FLUX_REACTOR_SIGCHLD
36-
The reactor will internally register a SIGCHLD handler and be capable
37-
of handling flux child watchers (see :man3:`flux_child_watcher_create`).
30+
be used to monitor for events on file descriptors, timers, and
31+
:type:`flux_t` broker handles. :var:`flags` should be set to zero.
3832

3933
For each event source and type that is to be monitored, a :type:`flux_watcher_t`
4034
object is created using a type-specific create function, and started

doc/man3/flux_signal_watcher_create.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ When one :var:`callback` is shared by multiple watchers, the signal number that
3737
triggered the event can be obtained with
3838
:func:`flux_signal_watcher_get_signum`.
3939

40+
Signal handling can be tricky in multi-threaded programs. It is advisable
41+
to handle signals in the main thread only. For example, block signals by
42+
calling :linux:man2:`sigprocmask` before spawning other threads, and register
43+
signal watchers only in the main thread.
4044

4145
RETURN VALUE
4246
============

doc/manpages.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@
7575
('man3/flux_attr_get', 'flux_attr_get', 'get/set Flux broker attributes', [author], 3),
7676
('man3/flux_aux_set', 'flux_aux_get', 'get/set auxiliary handle data', [author], 3),
7777
('man3/flux_aux_set', 'flux_aux_set', 'get/set auxiliary handle data', [author], 3),
78-
('man3/flux_child_watcher_create', 'flux_child_watcher_get_rpid', 'create child watcher', [author], 3),
79-
('man3/flux_child_watcher_create', 'flux_child_watcher_get_rstatus', 'create child watcher', [author], 3),
80-
('man3/flux_child_watcher_create', 'flux_child_watcher_create', 'create child watcher', [author], 3),
8178
('man3/flux_core_version', 'flux_core_version_string', 'get flux-core version', [author], 3),
8279
('man3/flux_core_version', 'flux_core_version', 'get flux-core version', [author], 3),
8380
('man3/flux_event_decode', 'flux_event_decode_raw', 'encode/decode a Flux event message', [author], 3),

doc/test/spell.en.pws

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,3 +940,4 @@ cPATH
940940
SATTR
941941
myprogram
942942
unref
943+
sigprocmask

src/broker/broker.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,15 @@ int main (int argc, char *argv[])
248248
* ctx.h is used conventionally within the broker for RPCs, message
249249
* handlers, etc. ctx.h_internal belongs to the broker's routing logic
250250
* and is accessed using flux_send() and flux_recv() only. Both handles
251-
* share a reactor, which is created with FLUX_REACTOR_SIGCHLD in order
252-
* to support libsubprocess.
251+
* share a reactor.
253252
*
254253
* N.B. since both handles are in the same thread, synchronous RPCs on
255254
* ctx.h will deadlock. The main broker reactor must run in order
256255
* to move messages from the interthread queue to the routing logic.
257256
* Careful with flux_attr_get(), which hides a synchronous RPC if the
258257
* requested value is not cached.
259258
*/
260-
if (!(ctx.reactor = flux_reactor_create (FLUX_REACTOR_SIGCHLD))
259+
if (!(ctx.reactor = flux_reactor_create (0))
261260
|| !(ctx.h = flux_open ("interthread://broker", 0))
262261
|| flux_set_reactor (ctx.h, ctx.reactor) < 0
263262
|| !(ctx.h_internal = flux_open ("interthread://broker", 0))

src/broker/test/runat.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ void badinput (flux_t *h)
350350
int main (int argc, char *argv[])
351351
{
352352
flux_t *h;
353-
flux_reactor_t *r;
354353

355354
plan (NO_PLAN);
356355

@@ -360,12 +359,8 @@ int main (int argc, char *argv[])
360359

361360
if (!(logs = zlist_new ()))
362361
BAIL_OUT ("zlist_new failed");
363-
if (!(r = flux_reactor_create (FLUX_REACTOR_SIGCHLD)))
364-
BAIL_OUT ("flux_reactor_create failed");
365362
if (!(h = flux_open ("loop://", 0)))
366363
BAIL_OUT ("could not create loop handle");
367-
if (flux_set_reactor (h, r) < 0)
368-
BAIL_OUT ("flux_set_reactor failed");
369364
if (flux_attr_set_cacheonly (h, "rank", "0") < 0)
370365
BAIL_OUT ("flux_attr_set_cacheonly rank failed");
371366
flux_log_set_redirect (h, diag_logger, NULL);
@@ -374,7 +369,6 @@ int main (int argc, char *argv[])
374369
basic (h);
375370
badinput (h);
376371

377-
flux_reactor_destroy (r);
378372
flux_close (h);
379373

380374
clear_list (logs);

src/cmd/builtin/proxy.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,8 @@ static int cmd_proxy (optparse_t *p, int ac, char *av[])
385385
free (uri);
386386
flux_log_set_appname (ctx.h, "proxy");
387387
ctx.proxy_user = getuid ();
388-
if (!(r = flux_reactor_create (FLUX_REACTOR_SIGCHLD)))
389-
log_err_exit ("flux_reactor_create");
390-
if (flux_set_reactor (ctx.h, r) < 0)
391-
log_err_exit ("flux_set_reactor");
388+
if (!(r = flux_get_reactor (ctx.h)))
389+
log_err_exit ("flux_get_reactor");
392390

393391
/* Register handler for loss of broker connection if --reconnect
394392
*/

src/cmd/flux-start.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ int start_session (const char *cmd_argz,
10741074
if (signal (SIGTTOU, SIG_IGN) == SIG_ERR)
10751075
log_err_exit ("signal");
10761076
}
1077-
if (!(ctx.reactor = flux_reactor_create (FLUX_REACTOR_SIGCHLD)))
1077+
if (!(ctx.reactor = flux_reactor_create (0)))
10781078
log_err_exit ("flux_reactor_create");
10791079
if (!(ctx.timer = flux_timer_watcher_create (ctx.reactor,
10801080
ctx.exit_timeout,

0 commit comments

Comments
 (0)