From 1df90e409495f685974c50d6b1ade95d05fe7678 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Fri, 6 Mar 2009 19:28:24 -0500 Subject: [PATCH] Fix race condition with initial sysdb creation When the sysdb LDB file does not exist on the system, the first attempt to connect to it will invoke a creation routine. However, both the NSS and the InfoPipe are started in parallel by the monitor, resulting in a race condition as they both try to initialize the sysdb. The easiest fix for this is to simply have the monitor create the sysdb before it launches NSS and InfoPipe. --- server/monitor/monitor.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c index 3c393c9..d797ae0 100644 --- a/server/monitor/monitor.c +++ b/server/monitor/monitor.c @@ -28,6 +28,7 @@ #include "popt.h" #include "tevent.h" #include "confdb/confdb.h" +#include "db/sysdb.h" #include "monitor/monitor.h" #include "dbus/dbus.h" #include "sbus/sssd_dbus.h" @@ -365,6 +366,7 @@ int monitor_process_init(TALLOC_CTX *mem_ctx, { struct mt_ctx *ctx; struct mt_svc *svc; + struct sysdb_ctx *sysdb; const char **doms; int dom_count; char *path; @@ -382,6 +384,18 @@ int monitor_process_init(TALLOC_CTX *mem_ctx, if (ret != EOK) return ret; + /* Avoid a startup race condition between InfoPipe + * and NSS. If the sysdb doesn't exist yet, both + * will try to create it at the same time. So + * we'll have the monitor create it before either of + * those processes start. + */ + ret = sysdb_init(mem_ctx, ctx->ev, ctx->cdb, + NULL, &sysdb); + if (ret != EOK) + return ret; + talloc_free(sysdb); + /* Initialize D-BUS Server * The monitor will act as a D-BUS server for all * SSSD processes */ -- 1.6.0.6