summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@codefactory.se>2003-02-16 10:20:04 +0000
committerAnders Carlsson <andersca@codefactory.se>2003-02-16 10:20:04 +0000
commit50137daea3b57a6f862691dad4f412bcc041e9bb (patch)
tree8d168d84595b641b06a5daf7aaf8a9a8d3b90df5
parent34b66d10eb8343f34ad6bfeb96cfea4498811a88 (diff)
2003-02-16 Anders Carlsson <andersca@codefactory.se>
* bus/dispatch.c: (bus_dispatch_message_handler): * dbus/dbus-errors.h: Return an error if someone tries to send a message to a service that doesn't exist.
-rw-r--r--ChangeLog7
-rw-r--r--bus/dispatch.c35
-rw-r--r--dbus/dbus-errors.h1
3 files changed, 39 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index afb58cf4..662ce240 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2003-02-16 Anders Carlsson <andersca@codefactory.se>
+ * bus/dispatch.c: (bus_dispatch_message_handler):
+ * dbus/dbus-errors.h:
+ Return an error if someone tries to send a message to a service
+ that doesn't exist.
+
+2003-02-16 Anders Carlsson <andersca@codefactory.se>
+
* bus/activation.c: (load_directory), (bus_activation_init),
(bus_activation_activate_service):
* bus/activation.h:
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 4e42f9a0..2ce26ae1 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -88,11 +88,38 @@ bus_dispatch_message_handler (DBusMessageHandler *handler,
_dbus_string_init_const (&service_string, service_name);
service = bus_service_lookup (&service_string, FALSE);
- _dbus_assert (bus_service_get_primary_owner (service) != NULL);
+ if (!service)
+ {
+ DBusMessage *error_reply;
+ DBusString error_message;
+ const char *error_str;
+
+ /* Trying to send a message to a non-existant service,
+ bounce back an error message. */
+
+ BUS_HANDLE_OOM (_dbus_string_init (&error_message, _DBUS_INT_MAX));
+
+ BUS_HANDLE_OOM (_dbus_string_append (&error_message, "Service \""));
+ BUS_HANDLE_OOM (_dbus_string_append (&error_message, service_name));
+ BUS_HANDLE_OOM (_dbus_string_append (&error_message, "does not exist"));
+
+ _dbus_string_get_const_data (&error_message, &error_str);
+ BUS_HANDLE_OOM (error_reply = dbus_message_new_error_reply (message, DBUS_ERROR_SERVICE_DOES_NOT_EXIST,
+ error_str));
+ _dbus_string_free (&error_message);
+
+ /* Dispatch the message */
+ BUS_HANDLE_OOM (dbus_connection_send_message (connection, error_reply, NULL, NULL));
+ dbus_message_unref (error_reply);
+ }
+ else
+ {
+ _dbus_assert (bus_service_get_primary_owner (service) != NULL);
- /* Dispatch the message */
- BUS_HANDLE_OOM (dbus_connection_send_message (bus_service_get_primary_owner (service),
- message, NULL, NULL));
+ /* Dispatch the message */
+ BUS_HANDLE_OOM (dbus_connection_send_message (bus_service_get_primary_owner (service),
+ message, NULL, NULL));
+ }
}
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
diff --git a/dbus/dbus-errors.h b/dbus/dbus-errors.h
index 1b7b474a..fd861feb 100644
--- a/dbus/dbus-errors.h
+++ b/dbus/dbus-errors.h
@@ -53,6 +53,7 @@ struct DBusError
#define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed"
#define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed"
#define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory"
+#define DBUS_ERROR_SERVICE_DOES_NOT_EXIST "org.freedesktop.DBus.Error.ServiceDoesNotExist"
typedef enum
{