summaryrefslogtreecommitdiff
path: root/server/sbus
diff options
context:
space:
mode:
Diffstat (limited to 'server/sbus')
-rw-r--r--server/sbus/sbus_client.c51
-rw-r--r--server/sbus/sbus_client.h12
-rw-r--r--server/sbus/sssd_dbus.h3
-rw-r--r--server/sbus/sssd_dbus_connection.c9
4 files changed, 22 insertions, 53 deletions
diff --git a/server/sbus/sbus_client.c b/server/sbus/sbus_client.c
index 25c56d85..971aa161 100644
--- a/server/sbus/sbus_client.c
+++ b/server/sbus/sbus_client.c
@@ -25,55 +25,38 @@
int sbus_client_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- const char *server_address,
struct sbus_method_ctx *sm_ctx,
- void *conn_pvt_data,
+ const char *server_address,
+ struct sbus_conn_ctx **_conn_ctx,
sbus_conn_destructor_fn destructor,
- struct service_sbus_ctx **srvs_ctx)
+ void *conn_pvt_data)
{
+ struct sbus_conn_ctx *conn_ctx = NULL;
int ret;
- TALLOC_CTX *tmp_ctx;
- struct service_sbus_ctx *ss_ctx;
/* Validate input */
if (server_address == NULL) {
return EINVAL;
}
- tmp_ctx = talloc_new(mem_ctx);
- if (tmp_ctx == NULL) {
- return ENOMEM;
- }
-
- ss_ctx = talloc_zero(tmp_ctx, struct service_sbus_ctx);
- if (ss_ctx == NULL) {
- ret = ENOMEM;
- goto done;
+ ret = sbus_new_connection(mem_ctx, ev, server_address, &conn_ctx);
+ if (ret != EOK) {
+ goto fail;
}
- ss_ctx->ev = ev;
-
- ret = sbus_new_connection(ss_ctx, ss_ctx->ev,
- server_address, &ss_ctx->scon_ctx,
- destructor);
- if (ret != EOK) goto done;
- ret = sbus_conn_add_method_ctx(ss_ctx->scon_ctx, sm_ctx);
- if (ret != EOK) goto done;
- ss_ctx->sm_ctx = sm_ctx;
- if (talloc_reference(ss_ctx, sm_ctx) == NULL) {
- ret = ENOMEM;
- goto done;
+ ret = sbus_conn_add_method_ctx(conn_ctx, sm_ctx);
+ if (ret != EOK) {
+ goto fail;
}
- if(conn_pvt_data) {
- sbus_conn_set_private_data(ss_ctx->scon_ctx, conn_pvt_data);
- }
+ /* Set connection destructor and private data */
+ sbus_conn_set_destructor(conn_ctx, destructor);
+ sbus_conn_set_private_data(conn_ctx, conn_pvt_data);
- talloc_steal(mem_ctx, ss_ctx);
- *srvs_ctx = ss_ctx;
- ret = EOK;
+ *_conn_ctx = conn_ctx;
+ return EOK;
-done:
- talloc_free(tmp_ctx);
+fail:
+ talloc_free(conn_ctx);
return ret;
}
diff --git a/server/sbus/sbus_client.h b/server/sbus/sbus_client.h
index 12c70401..98b5309c 100644
--- a/server/sbus/sbus_client.h
+++ b/server/sbus/sbus_client.h
@@ -25,18 +25,12 @@
#include "tevent.h"
#include "sbus/sssd_dbus.h"
-struct service_sbus_ctx {
- struct tevent_context *ev;
- struct sbus_conn_ctx *scon_ctx;
- struct sbus_method_ctx *sm_ctx;
-};
-
int sbus_client_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- const char *server_address,
struct sbus_method_ctx *sm_ctx,
- void *conn_pvt_data,
+ const char *server_address,
+ struct sbus_conn_ctx **_conn_ctx,
sbus_conn_destructor_fn destructor,
- struct service_sbus_ctx **srvs_ctx);
+ void *conn_pvt_data);
#endif /* SBUS_CLIENT_H_ */
diff --git a/server/sbus/sssd_dbus.h b/server/sbus/sssd_dbus.h
index b9c7a269..ddb1cb89 100644
--- a/server/sbus/sssd_dbus.h
+++ b/server/sbus/sssd_dbus.h
@@ -91,8 +91,7 @@ int sbus_new_server(TALLOC_CTX *mem_ctx,
*/
int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev,
const char *address,
- struct sbus_conn_ctx **conn_ctx,
- sbus_conn_destructor_fn destructor);
+ struct sbus_conn_ctx **conn_ctx);
/* sbus_add_connection
* Integrates a D-BUS connection with the TEvent main
diff --git a/server/sbus/sssd_dbus_connection.c b/server/sbus/sssd_dbus_connection.c
index 3ea09ca0..70ddefd9 100644
--- a/server/sbus/sssd_dbus_connection.c
+++ b/server/sbus/sssd_dbus_connection.c
@@ -244,13 +244,9 @@ static int sbus_add_connection_int(struct sbus_conn_ctx **_conn_ctx)
return EOK;
}
-/*int sbus_new_connection(struct sbus_method_ctx *ctx, const char *address,
- DBusConnection **connection,
- sbus_conn_destructor_fn destructor)*/
int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev,
const char *address,
- struct sbus_conn_ctx **conn_ctx,
- sbus_conn_destructor_fn destructor)
+ struct sbus_conn_ctx **conn_ctx)
{
DBusConnection *dbus_conn;
DBusError dbus_error;
@@ -278,9 +274,6 @@ int sbus_new_connection(TALLOC_CTX *ctx, struct tevent_context *ev,
dbus_connection_set_exit_on_disconnect((*conn_ctx)->dbus_conn, FALSE);
- /* Set connection destructor */
- sbus_conn_set_destructor(*conn_ctx, destructor);
-
return ret;
}