summaryrefslogtreecommitdiffstats
path: root/server/providers/data_provider_be.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-01-19 13:33:28 -0500
committerSimo Sorce <idra@samba.org>2009-01-27 08:39:48 -0500
commitd9f203e045c63c853ae60b47fb8013e92600c9f9 (patch)
tree7351223712002fdb31ce1787ad59ea65e051bb53 /server/providers/data_provider_be.c
parentf52c3c6a93f673ba422f5eee1788e2f5b70b3a6a (diff)
downloadsssd-d9f203e045c63c853ae60b47fb8013e92600c9f9.tar.gz
sssd-d9f203e045c63c853ae60b47fb8013e92600c9f9.tar.xz
sssd-d9f203e045c63c853ae60b47fb8013e92600c9f9.zip
Refactoring the monitor code and SBUS utility functions.
Diffstat (limited to 'server/providers/data_provider_be.c')
-rw-r--r--server/providers/data_provider_be.c70
1 files changed, 59 insertions, 11 deletions
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c
index ba9ea466c..a669564be 100644
--- a/server/providers/data_provider_be.c
+++ b/server/providers/data_provider_be.c
@@ -35,10 +35,11 @@
#include "db/sysdb.h"
#include "dbus/dbus.h"
#include "sbus/sssd_dbus.h"
-#include "sbus_interfaces.h"
#include "util/btreemap.h"
#include "providers/dp_backend.h"
-#include "util/service_helpers.h"
+#include "providers/dp_sbus.h"
+#include "monitor/monitor_sbus.h"
+#include "monitor/monitor_interfaces.h"
typedef int (*be_init_fn_t)(TALLOC_CTX *, struct be_mod_ops **, void **);
@@ -286,20 +287,35 @@ done:
* sbus channel to the monitor daemon */
static int mon_cli_init(struct be_ctx *ctx)
{
+ int ret;
+ char *sbus_address;
struct service_sbus_ctx *ss_ctx;
+ struct sbus_method_ctx *sm_ctx;
- /* Set up SBUS connection to the monitor */
- ss_ctx = sssd_service_sbus_init(ctx, ctx->ev, ctx->cdb,
- mon_sbus_methods, NULL);
- if (ss_ctx == NULL) {
- DEBUG(0, ("Could not initialize D-BUS.\n"));
- return ENOMEM;
+ /* Set up SBUS connection to the monitor */
+ ret = monitor_get_sbus_address(ctx, ctx->cdb, &sbus_address);
+ if (ret != EOK) {
+ DEBUG(0, ("Could not locate monitor address.\n"));
+ return ret;
}
- ctx->ss_ctx = ss_ctx;
+ ret = monitor_init_sbus_methods(ctx, mon_sbus_methods, &sm_ctx);
+ if (ret != EOK) {
+ DEBUG(0, ("Could not initialize SBUS methods.\n"));
+ return ret;
+ }
- /* attach be context to the connection */
- sbus_conn_set_private_data(ss_ctx->scon_ctx, ctx);
+ ret = sbus_client_init(ctx, ctx->ev,
+ sbus_address, sm_ctx,
+ ctx /* Private Data */,
+ NULL /* Destructor */,
+ &ss_ctx);
+ if (ret != EOK) {
+ DEBUG(0, ("Failed to connect to monitor services.\n"));
+ return ret;
+ }
+
+ ctx->ss_ctx = ss_ctx;
return EOK;
}
@@ -308,6 +324,38 @@ 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)
{
+ int ret;
+ char *sbus_address;
+ struct service_sbus_ctx *ss_ctx;
+ struct sbus_method_ctx *sm_ctx;
+
+ /* Set up SBUS connection to the data provider */
+ ret = dp_get_sbus_address(ctx, ctx->cdb, &sbus_address);
+ if (ret != EOK) {
+ DEBUG(0, ("Could not locate data provider address.\n"));
+ return ret;
+ }
+
+ ret = dp_init_sbus_methods(ctx, mon_sbus_methods, &sm_ctx);
+ if (ret != EOK) {
+ DEBUG(0, ("Could not initialize SBUS methods.\n"));
+ return ret;
+ }
+
+ ret = sbus_client_init(ctx, ctx->ev,
+ sbus_address, sm_ctx,
+ ctx /* Private Data */,
+ NULL /* Destructor */,
+ &ss_ctx);
+ if (ret != EOK) {
+ DEBUG(0, ("Failed to connect to data provider services.\n"));
+ return ret;
+ }
+
+ ctx->ss_ctx = ss_ctx;
+
+ return EOK;
+
return dp_sbus_cli_init(ctx, ctx->ev, ctx->cdb,
be_methods, ctx, NULL,
&ctx->dp_ctx);