summaryrefslogtreecommitdiffstats
path: root/server/monitor
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-08-05 14:11:12 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-08-10 09:42:20 -0400
commit11c621b5ee1a0cdc27610f8b172017764acc285e (patch)
tree181c9079440367711c66d7281fc0aecb458fee77 /server/monitor
parentf1e4471551aa74015579bff0b64735cc9b085b74 (diff)
downloadsssd-11c621b5ee1a0cdc27610f8b172017764acc285e.tar.gz
sssd-11c621b5ee1a0cdc27610f8b172017764acc285e.tar.xz
sssd-11c621b5ee1a0cdc27610f8b172017764acc285e.zip
Simplify interfaces initialization
Make as much as possible static, and remove use of talloc_reference and allocation/deallocation of memory when not necessary. Fix also responder use of rctx->conn, was mistakenly used for both monitor and dp connections.
Diffstat (limited to 'server/monitor')
-rw-r--r--server/monitor/monitor.c64
-rw-r--r--server/monitor/monitor_interfaces.h23
-rw-r--r--server/monitor/monitor_sbus.c35
-rw-r--r--server/monitor/monitor_sbus.h2
4 files changed, 37 insertions, 87 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index 7a27c4ec7..81012071f 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -171,45 +171,33 @@ static int dbus_get_monitor_version(DBusMessage *message,
}
struct sbus_method monitor_methods[] = {
- { MONITOR_METHOD_VERSION, dbus_get_monitor_version},
- {NULL, NULL}
+ { MON_SRV_METHOD_VERSION, dbus_get_monitor_version },
+ { NULL, NULL }
+};
+
+struct sbus_interface monitor_server_interface = {
+ MONITOR_DBUS_INTERFACE,
+ MONITOR_DBUS_PATH,
+ SBUS_DEFAULT_VTABLE,
+ monitor_methods,
+ NULL
};
/* monitor_dbus_init
* Set up the monitor service as a D-BUS Server */
static int monitor_dbus_init(struct mt_ctx *ctx)
{
- struct sbus_method_ctx *sd_ctx;
char *monitor_address;
int ret;
- sd_ctx = talloc_zero(ctx, struct sbus_method_ctx);
- if (!sd_ctx) {
- return ENOMEM;
- }
-
- monitor_address = talloc_asprintf(sd_ctx, "unix:path=%s/%s",
+ monitor_address = talloc_asprintf(ctx, "unix:path=%s/%s",
PIPE_PATH, SSSD_SERVICE_PIPE);
if (!monitor_address) {
- talloc_free(sd_ctx);
- return ENOMEM;
- }
-
- /* Set up globally-available D-BUS methods */
- sd_ctx->interface = talloc_strdup(sd_ctx, MONITOR_DBUS_INTERFACE);
- if (!sd_ctx->interface) {
- talloc_free(sd_ctx);
- return ENOMEM;
- }
- sd_ctx->path = talloc_strdup(sd_ctx, MONITOR_DBUS_PATH);
- if (!sd_ctx->path) {
- talloc_free(sd_ctx);
return ENOMEM;
}
- sd_ctx->methods = monitor_methods;
- sd_ctx->message_handler = sbus_message_handler;
- ret = sbus_new_server(ctx, ctx->ev, monitor_address, sd_ctx,
+ ret = sbus_new_server(ctx, ctx->ev,
+ monitor_address, &monitor_server_interface,
&ctx->sbus_srv, dbus_service_init, ctx);
talloc_free(monitor_address);
@@ -464,9 +452,9 @@ static int monitor_shutdown_service(struct mt_svc *svc)
/* Construct a shutdown message */
msg = dbus_message_new_method_call(NULL,
- SERVICE_PATH,
- SERVICE_INTERFACE,
- SERVICE_METHOD_SHUTDOWN);
+ MONITOR_PATH,
+ MONITOR_INTERFACE,
+ MON_CLI_METHOD_SHUTDOWN);
if (!msg) {
DEBUG(0,("Out of memory?!\n"));
monitor_kill_service(svc);
@@ -581,8 +569,8 @@ static int service_signal(struct mt_svc *svc, const char *svc_signal)
dbus_conn = sbus_get_connection(svc->mt_conn->conn);
msg = dbus_message_new_method_call(NULL,
- SERVICE_PATH,
- SERVICE_INTERFACE,
+ MONITOR_PATH,
+ MONITOR_INTERFACE,
svc_signal);
if (!msg) {
DEBUG(0,("Out of memory?!\n"));
@@ -610,11 +598,11 @@ static int service_signal(struct mt_svc *svc, const char *svc_signal)
static int service_signal_reload(struct mt_svc *svc)
{
- return service_signal(svc, SERVICE_METHOD_RELOAD);
+ return service_signal(svc, MON_CLI_METHOD_RELOAD);
}
static int service_signal_dns_reload(struct mt_svc *svc)
{
- return service_signal(svc, SERVICE_METHOD_RES_INIT);
+ return service_signal(svc, MON_CLI_METHOD_RES_INIT);
}
static int check_domain_ranges(struct sss_domain_info *domains)
@@ -1823,9 +1811,9 @@ static int dbus_service_init(struct sbus_connection *conn, void *data)
* for all services
*/
msg = dbus_message_new_method_call(NULL,
- SERVICE_PATH,
- SERVICE_INTERFACE,
- SERVICE_METHOD_IDENTITY);
+ MONITOR_PATH,
+ MONITOR_INTERFACE,
+ MON_CLI_METHOD_IDENTITY);
if (msg == NULL) {
DEBUG(0,("Out of memory?!\n"));
talloc_free(conn);
@@ -1970,9 +1958,9 @@ static int service_send_ping(struct mt_svc *svc)
* for all services
*/
msg = dbus_message_new_method_call(NULL,
- SERVICE_PATH,
- SERVICE_INTERFACE,
- SERVICE_METHOD_PING);
+ MONITOR_PATH,
+ MONITOR_INTERFACE,
+ MON_CLI_METHOD_PING);
if (!msg) {
DEBUG(0,("Out of memory?!\n"));
talloc_free(svc->mt_conn->conn);
diff --git a/server/monitor/monitor_interfaces.h b/server/monitor/monitor_interfaces.h
index 05d1bb416..5c58066d5 100644
--- a/server/monitor/monitor_interfaces.h
+++ b/server/monitor/monitor_interfaces.h
@@ -25,20 +25,19 @@
#define MONITOR_DBUS_INTERFACE "org.freedesktop.sssd.monitor"
#define MONITOR_DBUS_PATH "/org/freedesktop/sssd/monitor"
-/* Monitor Methods */
-#define MONITOR_METHOD_VERSION "getVersion"
+/* Monitor SRV Methods */
+#define MON_SRV_METHOD_VERSION "getVersion"
+/*** Monitor Interface ***/
-/*** Services ***/
+#define MONITOR_PATH "/org/freedesktop/sssd/service"
+#define MONITOR_INTERFACE "org.freedesktop.sssd.service"
-#define SERVICE_PATH "/org/freedesktop/sssd/service"
-#define SERVICE_INTERFACE "org.freedesktop.sssd.service"
-
-/* Service Methods */
-#define SERVICE_METHOD_IDENTITY "getIdentity"
-#define SERVICE_METHOD_PING "ping"
-#define SERVICE_METHOD_RELOAD "reloadConfig"
-#define SERVICE_METHOD_SHUTDOWN "shutDown"
-#define SERVICE_METHOD_RES_INIT "resInit"
+/* Monitor CLI Methods */
+#define MON_CLI_METHOD_IDENTITY "getIdentity"
+#define MON_CLI_METHOD_PING "ping"
+#define MON_CLI_METHOD_RELOAD "reloadConfig"
+#define MON_CLI_METHOD_SHUTDOWN "shutDown"
+#define MON_CLI_METHOD_RES_INIT "resInit"
#define SSSD_SERVICE_PIPE "private/sbus-monitor"
diff --git a/server/monitor/monitor_sbus.c b/server/monitor/monitor_sbus.c
index 5d49f003d..817b42ae6 100644
--- a/server/monitor/monitor_sbus.c
+++ b/server/monitor/monitor_sbus.c
@@ -54,38 +54,3 @@ done:
return ret;
}
-int monitor_init_sbus_methods(TALLOC_CTX *mem_ctx,
- struct sbus_method *methods,
- struct sbus_method_ctx **sm_ctx)
-{
- struct sbus_method_ctx *method_ctx;
- int ret;
-
- method_ctx = talloc_zero(mem_ctx, struct sbus_method_ctx);
- if (!method_ctx) {
- ret = ENOMEM;
- goto fail;
- }
-
- method_ctx->interface = talloc_strdup(method_ctx, SERVICE_INTERFACE);
- if (method_ctx->interface == NULL) {
- ret = ENOMEM;
- goto fail;
- }
-
- method_ctx->path = talloc_strdup(method_ctx, SERVICE_PATH);
- if (method_ctx->path == NULL) {
- ret = ENOMEM;
- goto fail;
- }
-
- method_ctx->methods = methods;
- method_ctx->message_handler = sbus_message_handler;
-
- *sm_ctx = method_ctx;
- return EOK;
-
-fail:
- talloc_free(method_ctx);
- return ret;
-}
diff --git a/server/monitor/monitor_sbus.h b/server/monitor/monitor_sbus.h
index 5e110ab87..bc36e88eb 100644
--- a/server/monitor/monitor_sbus.h
+++ b/server/monitor/monitor_sbus.h
@@ -24,7 +24,5 @@
int monitor_get_sbus_address(TALLOC_CTX *mem_ctx, struct confdb_ctx *confdb,
char **address);
-int monitor_init_sbus_methods(TALLOC_CTX *mem_ctx, struct sbus_method *methods,
- struct sbus_method_ctx **sm_ctx);
#endif /* MONITOR_SBUS_H_ */