From f52c3c6a93f673ba422f5eee1788e2f5b70b3a6a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 14 Jan 2009 15:52:48 -0500 Subject: 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. --- server/providers/data_provider.h | 2 ++ server/providers/data_provider_be.c | 18 +++--------------- server/providers/dp_helpers.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'server/providers') diff --git a/server/providers/data_provider.h b/server/providers/data_provider.h index bd610a53..a7311e5e 100644 --- a/server/providers/data_provider.h +++ b/server/providers/data_provider.h @@ -77,6 +77,8 @@ int dp_sbus_cli_init(TALLOC_CTX *mem_ctx, struct event_context *ev, struct confdb_ctx *cdb, struct sbus_method *methods, + void *conn_pvt_data, + sbus_conn_destructor_fn destructor, struct service_sbus_ctx **srvs_ctx); #endif /* __DATA_PROVIDER_ */ diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c index 75e99bdc..ba9ea466 100644 --- a/server/providers/data_provider_be.c +++ b/server/providers/data_provider_be.c @@ -308,21 +308,9 @@ static int mon_cli_init(struct be_ctx *ctx) * sbus channel to the data provider daemon */ static int be_cli_init(struct be_ctx *ctx) { - struct service_sbus_ctx *dp_ctx; - int ret; - - ret = dp_sbus_cli_init(ctx, ctx->ev, ctx->cdb, - be_methods, &dp_ctx); - if (ret != EOK) { - return ret; - } - - ctx->dp_ctx = dp_ctx; - - /* attach be context to the connection */ - sbus_conn_set_private_data(dp_ctx->scon_ctx, ctx); - - return EOK; + return dp_sbus_cli_init(ctx, ctx->ev, ctx->cdb, + be_methods, ctx, NULL, + &ctx->dp_ctx); } static int load_backend(struct be_ctx *ctx) diff --git a/server/providers/dp_helpers.c b/server/providers/dp_helpers.c index 99d65f45..52dc69e1 100644 --- a/server/providers/dp_helpers.c +++ b/server/providers/dp_helpers.c @@ -25,6 +25,8 @@ int dp_sbus_cli_init(TALLOC_CTX *mem_ctx, struct event_context *ev, struct confdb_ctx *cdb, struct sbus_method *methods, + void *conn_pvt_data, + sbus_conn_destructor_fn destructor, struct service_sbus_ctx **srvs_ctx) { struct service_sbus_ctx *ss_ctx; @@ -87,6 +89,14 @@ int dp_sbus_cli_init(TALLOC_CTX *mem_ctx, sm_ctx->message_handler = sbus_message_handler; sbus_conn_add_method_ctx(ss_ctx->scon_ctx, sm_ctx); + if (conn_pvt_data) { + sbus_conn_set_private_data(ss_ctx->scon_ctx, conn_pvt_data); + } + + if (destructor) { + sbus_conn_set_destructor(ss_ctx->scon_ctx, destructor); + } + talloc_steal(mem_ctx, ss_ctx); *srvs_ctx = ss_ctx; ret = EOK; -- cgit