From cc20b5c9b26dec7a97c922caa28f6ebf454f9c54 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 13 Nov 2006 17:23:32 +0000 Subject: [PATCH] Send reply before doing autostart --- hcid/dbus-manager.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c index e538a7381..55c601ae7 100644 --- a/hcid/dbus-manager.c +++ b/hcid/dbus-manager.c @@ -260,6 +260,7 @@ static DBusHandlerResult register_service(DBusConnection *conn, DBusMessage *msg, void *data) { const char *path, *name, *description; + DBusHandlerResult result; DBusMessage *message; DBusError err; int reg_err; @@ -290,10 +291,16 @@ static DBusHandlerResult register_service(DBusConnection *conn, /* Report that a new service was registered */ message = dbus_message_new_signal(BASE_PATH, MANAGER_INTERFACE, "ServiceRegistered"); + dbus_message_append_args(message, DBUS_TYPE_STRING, &path, - DBUS_TYPE_INVALID); + DBUS_TYPE_INVALID); + send_message_and_unref(conn, message); + result = send_message_and_unref(conn, dbus_message_new_method_return(msg)); + + dbus_connection_flush(conn); + /* If autostart feature is enabled: send the Start message to the service agent */ if (autostart) { DBusPendingCall *pending; @@ -307,20 +314,22 @@ static DBusHandlerResult register_service(DBusConnection *conn, if (dbus_connection_send_with_reply(conn, message, &pending, START_REPLY_TIMEOUT) == FALSE) { dbus_message_unref(message); - goto fail; + return result; } + dbus_connection_flush(conn); + dbus_connection_get_object_path_data(conn, path, (void *) &agent); call = service_call_new(conn, message, agent); dbus_message_unref(message); if (!call) - goto fail; + return result; dbus_pending_call_set_notify(pending, autostart_reply, call, service_call_free); } -fail: - return send_message_and_unref(conn, dbus_message_new_method_return(msg)); + + return result; } static DBusHandlerResult unregister_service(DBusConnection *conn,