summaryrefslogtreecommitdiff
path: root/src/monitor
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-10-26 12:46:48 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-11-06 12:02:45 +0100
commitd19c4785215305e6eb5f2fa2fc503a2ba50d3f10 (patch)
treeff41cfae50f50a16dba23c9106acc98f82ea7cbd /src/monitor
parent715e09ece039af851b96bcf1861c4fff6169d499 (diff)
downloadsssd-d19c4785215305e6eb5f2fa2fc503a2ba50d3f10.tar.gz
sssd-d19c4785215305e6eb5f2fa2fc503a2ba50d3f10.tar.bz2
sssd-d19c4785215305e6eb5f2fa2fc503a2ba50d3f10.zip
create pid file immediately after fork again
Related to https://fedorahosted.org/sssd/ticket/1357 We realized that sysv and systemd does not use pid file existence as a notification of finished initialization. Therefore, we create the pid file in server_setup() again. We are removing check_file() from monitor main(), it is handled by server_setup() during pid file creation. This check was previously included in e7dd2a5102ba6cfd28be6eccdd62768e9758d9f4.
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index e08ffb9a..fac16442 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -156,7 +156,6 @@ struct mt_ctx {
struct netlink_ctx *nlctx;
const char *conf_path;
struct sss_sigchild_ctx *sigchld_ctx;
- bool pid_file_created;
bool is_daemon;
pid_t parent_pid;
};
@@ -438,20 +437,7 @@ static int mark_service_as_started(struct mt_svc *svc)
ctx->started_services++;
}
- /* create the pid file if all services are alive */
- 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);
- if (ret != EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE,
- ("Error creating pidfile: %s/%s.pid! (%d [%s])\n",
- PID_PATH, MONITOR_NAME, ret, strerror(ret)));
- kill(getpid(), SIGTERM);
- }
-
- ctx->pid_file_created = true;
-
+ if (ctx->started_services == ctx->num_services) {
/* Initialization is complete, terminate parent process if in daemon
* mode. Make sure we send the signal to the right process */
if (ctx->is_daemon) {
@@ -1473,7 +1459,6 @@ static errno_t load_configuration(TALLOC_CTX *mem_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);
@@ -2592,6 +2577,9 @@ int main(int argc, const char *argv[])
return 6;
}
+ /* we want a pid file check */
+ flags |= FLAGS_PID_FILE;
+
/* Open before server_setup() does to have logging
* during configuration checking */
if (debug_to_file) {
@@ -2635,15 +2623,6 @@ int main(int argc, const char *argv[])
"netgroup nsswitch maps.");
}
- /* Check if the SSSD is already running */
- ret = check_file(SSSD_PIDFILE_PATH, 0, 0, 0600, CHECK_REG, NULL, false);
- if (ret == EOK) {
- DEBUG(SSSDBG_FATAL_FAILURE,
- ("pidfile exists at %s\n", SSSD_PIDFILE_PATH));
- ERROR("SSSD is already running\n");
- return 2;
- }
-
/* Parse config file, fail if cannot be done */
ret = load_configuration(tmp_ctx, config_file, &monitor);
if (ret != EOK) {