diff options
author | Stef Walter <stefw@redhat.com> | 2014-02-18 14:32:54 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-03-14 13:42:20 +0100 |
commit | 07e941c1bbdc752142bbd3b838c540bc7ecd0ed7 (patch) | |
tree | 56453ab3ece875a6f80fc374fadaef07584484b7 /src/responder/common | |
parent | d9577dbd92555b0755881e37724019ef9c578404 (diff) | |
download | sssd-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/responder/common')
-rw-r--r-- | src/responder/common/responder.h | 18 | ||||
-rw-r--r-- | src/responder/common/responder_common.c | 27 |
2 files changed, 31 insertions, 14 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h index 3cf801516..479cd4c5e 100644 --- a/src/responder/common/responder.h +++ b/src/responder/common/responder.h @@ -70,7 +70,6 @@ struct be_conn { struct sss_domain_info *domain; char *sbus_address; - struct sbus_interface *intf; struct sbus_connection *conn; }; @@ -144,7 +143,16 @@ struct sss_cmd_table { int (*fn)(struct cli_ctx *cctx); }; -/* responder_common.c */ +/* from generated code */ +struct mon_cli_iface; + +/* + * responder_common.c + * + * NOTE: We would like to use more strong typing for the @dp_vtable argument + * but can't since it accepts either a struct data_provider_iface + * or struct data_provider_rev_iface. So pass the base struct: sbus_vtable + */ int sss_process_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct confdb_ctx *cdb, @@ -154,9 +162,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx, const char *confdb_service_path, const char *svc_name, uint16_t svc_version, - struct sbus_interface *monitor_intf, + struct mon_cli_iface *monitor_intf, const char *cli_name, - struct sbus_interface *dp_intf, + struct sbus_vtable *dp_intf, struct resp_ctx **responder_ctx); int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain, @@ -207,7 +215,7 @@ struct dp_callback_ctx { void handle_requests_after_reconnect(struct resp_ctx *rctx); -int responder_logrotate(struct sbus_request *dbus_req); +int responder_logrotate(struct sbus_request *dbus_req, void *data); /* Each responder-specific request must create a constructor * function that creates a DBus Message that would be sent to diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 209bf5b01..9abda18d0 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -535,10 +535,11 @@ static void idle_handler(struct tevent_context *ev, } static int sss_dp_init(struct resp_ctx *rctx, - struct sbus_interface *intf, + struct sbus_vtable *dp_intf, const char *cli_name, struct sss_domain_info *domain) { + struct sbus_interface *intf; struct be_conn *be_conn; int ret; @@ -547,7 +548,6 @@ static int sss_dp_init(struct resp_ctx *rctx, be_conn->cli_name = cli_name; be_conn->domain = domain; - be_conn->intf = intf; be_conn->rctx = rctx; /* Set up SBUS connection to the monitor */ @@ -558,13 +558,23 @@ static int sss_dp_init(struct resp_ctx *rctx, } ret = sbus_client_init(rctx, rctx->ev, be_conn->sbus_address, - intf, &be_conn->conn, - NULL, rctx); + &be_conn->conn); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Failed to connect to monitor services.\n"); return ret; } + intf = sbus_new_interface(rctx, DP_PATH, dp_intf, rctx); + if (!intf) { + ret = ENOMEM; + } else { + ret = sbus_conn_add_interface(be_conn->conn, intf); + } + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export data provider.\n"); + return ret; + } + DLIST_ADD_END(rctx->be_conns, be_conn, struct be_conn *); /* Identify ourselves to the DP */ @@ -763,9 +773,9 @@ int sss_process_init(TALLOC_CTX *mem_ctx, const char *confdb_service_path, const char *svc_name, uint16_t svc_version, - struct sbus_interface *monitor_intf, + struct mon_cli_iface *monitor_intf, const char *cli_name, - struct sbus_interface *dp_intf, + struct sbus_vtable *dp_intf, struct resp_ctx **responder_ctx) { struct resp_ctx *rctx; @@ -990,11 +1000,10 @@ done: return ret; } -int responder_logrotate(struct sbus_request *dbus_req) +int responder_logrotate(struct sbus_request *dbus_req, void *data) { errno_t ret; - struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), - struct resp_ctx); + struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); ret = monitor_common_rotate_logs(rctx->cdb, rctx->confdb_service_path); if (ret != EOK) return ret; |