diff options
author | Simo Sorce <idra@samba.org> | 2009-02-24 16:36:16 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2009-02-24 16:50:08 -0500 |
commit | 57df88bb0b4ce656855410a8c2969d93475c2f11 (patch) | |
tree | 644bf0ce008c446efc27cf369d18a248da5ae7b4 /server/monitor | |
parent | 3621d86ad205dcacb50022f8e6b669218600257f (diff) | |
download | sssd-57df88bb0b4ce656855410a8c2969d93475c2f11.tar.gz sssd-57df88bb0b4ce656855410a8c2969d93475c2f11.tar.bz2 sssd-57df88bb0b4ce656855410a8c2969d93475c2f11.zip |
Proper fix for memory handling problem.
sbus_message_handler is not responsible anymore for sending
back data in any case.
Transfer this responsibility to the handler function called.
This way both synchronous and asynchronous funstions use the
interface the same way and can properly free memory referenced
by the reply after the send buffer has been filled in and all
copies are done in sbus_conn_send_reply()
Diffstat (limited to 'server/monitor')
-rw-r--r-- | server/monitor/monitor.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c index 166cf3cd..759a6881 100644 --- a/server/monitor/monitor.c +++ b/server/monitor/monitor.c @@ -88,22 +88,25 @@ static void set_global_checker(struct mt_ctx *ctx); /* dbus_get_monitor_version * Return the monitor version over D-BUS */ static int dbus_get_monitor_version(DBusMessage *message, - void *data, - DBusMessage **r) + struct sbus_conn_ctx *sconn) { const char *version = MONITOR_VERSION; DBusMessage *reply; dbus_bool_t ret; reply = dbus_message_new_method_return(message); + if (!reply) return ENOMEM; ret = dbus_message_append_args(reply, DBUS_TYPE_STRING, &version, DBUS_TYPE_INVALID); - if (!ret) { + dbus_message_unref(reply); return EIO; } - *r = reply; + /* send reply back */ + sbus_conn_send_reply(sconn, reply); + dbus_message_unref(reply); + return EOK; } @@ -525,14 +528,12 @@ static int dbus_service_init(struct sbus_conn_ctx *conn_ctx, void *data) DBusMessage *msg; DBusPendingCall *pending_reply; DBusConnection *conn; - DBusError dbus_error; dbus_bool_t dbret; DEBUG(3, ("Initializing D-BUS Service\n")); ctx = talloc_get_type(data, struct mt_ctx); conn = sbus_get_connection(conn_ctx); - dbus_error_init(&dbus_error); /* hang off this memory to the connection so that when the connection * is freed we can call a destructor to clear up the structure and @@ -633,6 +634,7 @@ static void identity_check(DBusPendingCall *pending, void *data) DBUS_TYPE_INVALID); if (!ret) { DEBUG(1,("Failed, to parse message, killing connection\n")); + if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error); sbus_disconnect(conn_ctx); goto done; } @@ -694,7 +696,6 @@ static int service_send_ping(struct mt_svc *svc) DBusMessage *msg; DBusPendingCall *pending_reply; DBusConnection *conn; - DBusError dbus_error; dbus_bool_t dbret; if (!svc->mt_conn) { @@ -704,7 +705,6 @@ static int service_send_ping(struct mt_svc *svc) DEBUG(4,("Pinging %s\n", svc->name)); conn = sbus_get_connection(svc->mt_conn->conn_ctx); - dbus_error_init(&dbus_error); /* * Set up identity request @@ -746,13 +746,11 @@ static void ping_check(DBusPendingCall *pending, void *data) struct mt_svc *svc; struct sbus_conn_ctx *conn_ctx; DBusMessage *reply; - DBusError dbus_error; const char *dbus_error_name; int type; svc = talloc_get_type(data, struct mt_svc); conn_ctx = svc->mt_conn->conn_ctx; - dbus_error_init(&dbus_error); reply = dbus_pending_call_steal_reply(pending); if (!reply) { |