summaryrefslogtreecommitdiffstats
path: root/server/monitor.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-01-14 15:52:48 -0500
committerSimo Sorce <idra@samba.org>2009-01-14 15:52:48 -0500
commitf52c3c6a93f673ba422f5eee1788e2f5b70b3a6a (patch)
treece9816cc678402cd90d796ffeca6e273de7fd487 /server/monitor.c
parent2a729edfe36c7519c48b9b4225fc84be6775da08 (diff)
downloadsssd-f52c3c6a93f673ba422f5eee1788e2f5b70b3a6a.tar.gz
sssd-f52c3c6a93f673ba422f5eee1788e2f5b70b3a6a.tar.xz
sssd-f52c3c6a93f673ba422f5eee1788e2f5b70b3a6a.zip
Add code to make it easier to reconnect in case the server
is not available immediately or drops the dbus connection. First step is the nss connection to the data provider.
Diffstat (limited to 'server/monitor.c')
-rw-r--r--server/monitor.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/server/monitor.c b/server/monitor.c
index 921e8b59a..369047913 100644
--- a/server/monitor.c
+++ b/server/monitor.c
@@ -37,7 +37,7 @@
/* ping time cannot be less then once every few seconds or the
* monitor will get crazy hammering children with messages */
-#define MONITOR_MIN_PING_TIME 10
+#define MONITOR_DEF_PING_TIME 10
struct mt_conn {
struct sbus_conn_ctx *conn_ctx;
@@ -55,6 +55,8 @@ struct mt_svc {
char *name;
pid_t pid;
+ int ping_time;
+
int restarts;
time_t last_restart;
time_t last_pong;
@@ -68,7 +70,6 @@ struct mt_ctx {
struct sbus_srv_ctx *sbus_srv;
int service_id_timeout;
- int service_ping_time;
};
static int start_service(struct mt_svc *mt_svc);
@@ -260,7 +261,7 @@ static void set_tasks_checker(struct mt_svc *svc)
struct timeval tv;
gettimeofday(&tv, NULL);
- tv.tv_sec += svc->mt_ctx->service_ping_time;
+ tv.tv_sec += svc->ping_time;
tv.tv_usec = 0;
te = event_add_timed(svc->mt_ctx->ev, svc, tv, tasks_check_handler, svc);
if (te == NULL) {
@@ -281,15 +282,6 @@ int get_monitor_config(struct mt_ctx *ctx)
return ret;
}
- ret = confdb_get_int(ctx->cdb, ctx,
- "config/services/monitor", "servicePingTime",
- MONITOR_MIN_PING_TIME, &ctx->service_ping_time);
- if (ret != EOK) {
- return ret;
- }
- if (ctx->service_ping_time < MONITOR_MIN_PING_TIME)
- ctx->service_ping_time = MONITOR_MIN_PING_TIME;
-
ret = confdb_get_param(ctx->cdb, ctx,
"config/services", "activeServices",
&ctx->services);
@@ -355,6 +347,15 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
talloc_free(svc);
continue;
}
+
+ ret = confdb_get_int(cdb, svc, path, "timeout",
+ MONITOR_DEF_PING_TIME, &svc->ping_time);
+ if (ret != EOK) {
+ DEBUG(0,("Failed to start service '%s'\n", svc->name));
+ talloc_free(svc);
+ continue;
+ }
+
talloc_free(path);
/* Add this service to the queue to be started once the monitor
@@ -397,6 +398,16 @@ int monitor_process_init(TALLOC_CTX *mem_ctx,
continue;
}
+ ret = confdb_get_int(cdb, svc, path, "timeout",
+ MONITOR_DEF_PING_TIME, &svc->ping_time);
+ if (ret != EOK) {
+ DEBUG(0,("Failed to start service '%s'\n", svc->name));
+ talloc_free(svc);
+ continue;
+ }
+
+ talloc_free(path);
+
/* if no command is present do not run the domain */
if (svc->command == NULL) {
/* the LOCAL domain does not need a backend at the moment */