summaryrefslogtreecommitdiffstats
path: root/server/monitor/monitor.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-01-26 09:37:32 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-02-01 08:50:57 -0500
commit3994ec2219ab7c7d5afbea4dad189d6920f94bbc (patch)
tree0a3067bd3b2ffee161722c472050165bcd07905c /server/monitor/monitor.c
parent4db27bb50ae891e6a9d99cce5f80ff73fd9d618f (diff)
downloadsssd-3994ec2219ab7c7d5afbea4dad189d6920f94bbc.tar.gz
sssd-3994ec2219ab7c7d5afbea4dad189d6920f94bbc.tar.xz
sssd-3994ec2219ab7c7d5afbea4dad189d6920f94bbc.zip
Force offline operation with SIGUSR1
If the monitor receives SIGUSR1, it will instruct all providers to enter offline operation. If any individual provider receives SIGUSR1, it alone will enter offline operation.
Diffstat (limited to 'server/monitor/monitor.c')
-rw-r--r--server/monitor/monitor.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index b3174bdab..85f69c113 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -858,6 +858,10 @@ static int service_signal_dns_reload(struct mt_svc *svc)
{
return service_signal(svc, MON_CLI_METHOD_RES_INIT);
}
+static int service_signal_offline(struct mt_svc *svc)
+{
+ return service_signal(svc, MON_CLI_METHOD_OFFLINE);
+}
static int check_domain_ranges(struct sss_domain_info *domains)
{
@@ -1489,6 +1493,7 @@ static void monitor_quit(struct tevent_context *ev,
void *siginfo,
void *private_data)
{
+ DEBUG(8, ("Received shutdown command\n"));
monitor_cleanup();
#if HAVE_GETPGRP
@@ -1501,6 +1506,29 @@ static void monitor_quit(struct tevent_context *ev,
exit(0);
}
+static void signal_offline(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ struct mt_ctx *monitor;
+ struct mt_svc *cur_svc;
+
+ monitor = talloc_get_type(private_data, struct mt_ctx);
+
+ DEBUG(8, ("Signaling providers to go offline immediately.\n"));
+
+ /* Signal all providers to immediately go offline */
+ for(cur_svc = monitor->svc_list; cur_svc; cur_svc = cur_svc->next) {
+ /* Don't signal services, only providers */
+ if (cur_svc->provider) {
+ service_signal_offline(cur_svc);
+ }
+ }
+}
+
int read_config_file(const char *config_file)
{
int ret;
@@ -2098,6 +2126,14 @@ int monitor_process_init(struct mt_ctx *ctx,
return EIO;
}
+ /* Handle SIGUSR1 (tell all providers to go offline) */
+ BlockSignals(false, SIGUSR1);
+ tes = tevent_add_signal(ctx->ev, ctx, SIGUSR1, 0,
+ signal_offline, ctx);
+ if (tes == NULL) {
+ return EIO;
+ }
+
return EOK;
}