summaryrefslogtreecommitdiffstats
path: root/src/monitor/monitor_sbus.c
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-02-18 14:32:54 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-03-14 13:42:20 +0100
commit07e941c1bbdc752142bbd3b838c540bc7ecd0ed7 (patch)
tree56453ab3ece875a6f80fc374fadaef07584484b7 /src/monitor/monitor_sbus.c
parentd9577dbd92555b0755881e37724019ef9c578404 (diff)
downloadsssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.tar.gz
sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.tar.xz
sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.zip
sbus: Refactor how we export DBus interfaces
Most importantly, stop using per connection private data. This doesn't scale when you have more than one thing exporting or exported on a connection. Remove struct sbus_interface and expand sbus_conn_add_interface() function. Remove various struct sbus_interface args to connection initialization functions and make callers use sbus_conn_add_interface() directly. The old method was optimized for exporting one interface on a connection. We'll have connections that export zero, one or more interfaces. To export an interface on a DBus server, call sbus_conn_add_interface() from within the sbus_server_conn_init_fn. To export an interface on a DBus client, call sbus_conn_add_interface() after sbus_new_connection() returns. As before struct sbus_interface represents an object exported via DBus. However it is now talloc allocated. One can set instance data on the struct sbus_interface. This instance data is passed to the various handlers and used in their implementation. However, we now have type safe interface exporting in the various high level sss_process_init() sss_monitor_init() and so on. Introspection support was not in use, and is now gone until we implement it using the metadata (future patch). Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/monitor/monitor_sbus.c')
-rw-r--r--src/monitor/monitor_sbus.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c
index 92d483233..544407ca2 100644
--- a/src/monitor/monitor_sbus.c
+++ b/src/monitor/monitor_sbus.c
@@ -144,12 +144,12 @@ int monitor_common_send_id(struct sbus_connection *conn,
return retval;
}
-int monitor_common_pong(struct sbus_request *dbus_req)
+int monitor_common_pong(struct sbus_request *dbus_req, void *data)
{
return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
}
-int monitor_common_res_init(struct sbus_request *dbus_req)
+int monitor_common_res_init(struct sbus_request *dbus_req, void *data)
{
int ret;
@@ -198,7 +198,7 @@ errno_t monitor_common_rotate_logs(struct confdb_ctx *confdb,
errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
- struct sbus_interface *intf,
+ struct mon_cli_iface *mon_iface,
const char *svc_name,
uint16_t svc_version,
void *pvt,
@@ -206,6 +206,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
{
errno_t ret;
char *sbus_address;
+ struct sbus_interface *intf;
struct sbus_connection *conn;
/* Set up SBUS connection to the monitor */
@@ -215,9 +216,7 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
return ret;
}
- ret = sbus_client_init(mem_ctx, ev, sbus_address,
- intf, &conn,
- NULL, pvt);
+ ret = sbus_client_init(mem_ctx, ev, sbus_address, &conn);
if (ret != EOK) {
DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n");
talloc_free(sbus_address);
@@ -225,6 +224,17 @@ errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
}
talloc_free(sbus_address);
+ intf = sbus_new_interface(mem_ctx, MONITOR_PATH, &mon_iface->vtable, pvt);
+ if (!intf) {
+ ret = ENOMEM;
+ } else {
+ ret = sbus_conn_add_interface(conn, intf);
+ }
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export monitor client.\n");
+ return ret;
+ }
+
/* Identify ourselves to the monitor */
ret = monitor_common_send_id(conn, svc_name, svc_version);
if (ret != EOK) {