summaryrefslogtreecommitdiff
path: root/src/monitor
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-10-05 11:51:09 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-10-05 18:50:27 +0200
commitbea5638a3be2834bbd6cb6755bb0d5fe19bfbffa (patch)
tree601b625c39ec8e42f5cd45dfd45ade5ced9a91d3 /src/monitor
parent09df21597db6fa5e8b954bea810b9bf7c98bafb4 (diff)
downloadsssd-bea5638a3be2834bbd6cb6755bb0d5fe19bfbffa.tar.gz
sssd-bea5638a3be2834bbd6cb6755bb0d5fe19bfbffa.tar.bz2
sssd-bea5638a3be2834bbd6cb6755bb0d5fe19bfbffa.zip
do not create pid file twice
If a provider is terminated and the monitor tries to restart it, it goes again through mark_service_as_started() which will try to create pid file again because number of running services didn't change. Because the pid file cannot be created twice, it will not return EOK and the whole SSSD is terminated.
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index a9dd1ffd..a5653999 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -156,6 +156,7 @@ struct mt_ctx {
struct netlink_ctx *nlctx;
const char *conf_path;
struct sss_sigchild_ctx *sigchld_ctx;
+ bool pid_file_created;
};
static int start_service(struct mt_svc *mt_svc);
@@ -436,7 +437,7 @@ static int mark_service_as_started(struct mt_svc *svc)
}
/* create the pid file if all services are alive */
- if (ctx->started_services == ctx->num_services) {
+ if (!ctx->pid_file_created && ctx->started_services == ctx->num_services) {
DEBUG(SSSDBG_TRACE_FUNC, ("All services have successfully started, "
"creating pid file\n"));
ret = pidfile(PID_PATH, MONITOR_NAME);
@@ -446,6 +447,8 @@ static int mark_service_as_started(struct mt_svc *svc)
PID_PATH, MONITOR_NAME, ret, strerror(ret)));
kill(getpid(), SIGTERM);
}
+
+ ctx->pid_file_created = true;
}
done:
@@ -1429,6 +1432,8 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx,
if(!ctx) {
return ENOMEM;
}
+
+ ctx->pid_file_created = false;
talloc_set_destructor((TALLOC_CTX *)ctx, monitor_ctx_destructor);
cdb_file = talloc_asprintf(ctx, "%s/%s", DB_PATH, CONFDB_FILE);