summaryrefslogtreecommitdiff
path: root/source3/printing/spoolssd.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-05-19 23:56:02 -0400
committerAndreas Schneider <asn@samba.org>2011-08-10 18:14:04 +0200
commit1155280a483e2a84e8baa27556c6ea066dbe6c8a (patch)
tree39c58cbdcb491651b4129233010154fe6e11842a /source3/printing/spoolssd.c
parentd36a8dc896d2a814dd18f127593a8382e4004213 (diff)
downloadsamba-1155280a483e2a84e8baa27556c6ea066dbe6c8a.tar.gz
samba-1155280a483e2a84e8baa27556c6ea066dbe6c8a.tar.bz2
samba-1155280a483e2a84e8baa27556c6ea066dbe6c8a.zip
s3-prefork: Set up a SIGCHLD handler by default
We need to properly handle preforked children so it is better to just do that automatically. If the parent needs/wants to intercept SIGCHLD events it can set a callback that will be called by the prefork code once the internal cleanup function that checks all prefork children has been executed. Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/printing/spoolssd.c')
-rw-r--r--source3/printing/spoolssd.c53
1 files changed, 14 insertions, 39 deletions
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index eb7b5e9b83..107ae58fe4 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -228,7 +228,7 @@ static bool spoolss_shutdown_cb(void *ptr)
return true;
}
-/* Childrens */
+/* Children */
struct spoolss_chld_sig_hup_ctx {
struct messaging_context *msg_ctx;
@@ -537,21 +537,21 @@ static void check_updater_child(void)
}
}
-static void spoolssd_sig_chld_handler(struct tevent_context *ev_ctx,
- struct tevent_signal *se,
- int signum, int count,
- void *siginfo, void *pvt)
+static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
+ struct prefork_pool *pfp,
+ struct timeval current_time);
+static void spoolssd_check_children(struct tevent_context *ev_ctx,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *pvt);
+
+static void spoolssd_sigchld_handler(struct tevent_context *ev_ctx,
+ struct prefork_pool *pfp,
+ void *private_data)
{
- struct prefork_pool *pfp;
int active, total;
int n, r;
- pfp = talloc_get_type_abort(pvt, struct prefork_pool);
-
- /* run the cleanup function to make sure all dead children are
- * properly and timely retired. */
- prefork_cleanup_loop(pfp);
-
/* now check we do not descend below the minimum */
active = prefork_count_active_children(pfp, &total);
@@ -574,38 +574,13 @@ static void spoolssd_sig_chld_handler(struct tevent_context *ev_ctx,
check_updater_child();
}
-static bool spoolssd_setup_sig_chld_handler(struct tevent_context *ev_ctx,
- struct prefork_pool *pfp)
-{
- struct tevent_signal *se;
-
- se = tevent_add_signal(ev_ctx, ev_ctx, SIGCHLD, 0,
- spoolssd_sig_chld_handler, pfp);
- if (!se) {
- DEBUG(0, ("Failed to setup SIGCHLD handler!\n"));
- return false;
- }
-
- return true;
-}
-
-static bool spoolssd_schedule_check(struct tevent_context *ev_ctx,
- struct prefork_pool *pfp,
- struct timeval current_time);
-static void spoolssd_check_children(struct tevent_context *ev_ctx,
- struct tevent_timer *te,
- struct timeval current_time,
- void *pvt);
-
static bool spoolssd_setup_children_monitor(struct tevent_context *ev_ctx,
struct prefork_pool *pfp)
{
bool ok;
- ok = spoolssd_setup_sig_chld_handler(ev_ctx, pfp);
- if (!ok) {
- return false;
- }
+ /* add our oun sigchld callback */
+ prefork_set_sigchld_callback(pfp, spoolssd_sigchld_handler, NULL);
ok = spoolssd_schedule_check(ev_ctx, pfp, tevent_timeval_current());
return ok;