From bea5638a3be2834bbd6cb6755bb0d5fe19bfbffa Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Fri, 5 Oct 2012 11:51:09 +0200 Subject: 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. --- src/monitor/monitor.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/monitor') 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); -- cgit