summaryrefslogtreecommitdiff
path: root/test/test-service.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-07 23:28:16 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-07 23:28:16 +0000
commitfe22b2194d53061fefe64d48ff6a53e6a762279d (patch)
tree590e2096930716d80fb2ba1ebfce10c10e08efda /test/test-service.c
parent1617fbe36c0bc2952093fc167b6edffdf32c445e (diff)
downloaddbus-fe22b2194d53061fefe64d48ff6a53e6a762279d.tar.gz
2003-04-07 Havoc Pennington <hp@redhat.com>
* doc/dbus-specification.sgml: require that base service names start with ':' and that the base service is created/deleted as first and last things a connection does on the bus * bus/dispatch.c (check_existent_service_activation): lots more work on the activation test; it doesn't fully pass yet... * test/test-service.c (main): fix so we don't memleak the connection to the message bus (filter_func): accept a message asking us to exit
Diffstat (limited to 'test/test-service.c')
-rw-r--r--test/test-service.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/test-service.c b/test/test-service.c
index a1f2ae34..a9a960a1 100644
--- a/test/test-service.c
+++ b/test/test-service.c
@@ -2,6 +2,17 @@
#include "test-utils.h"
static DBusLoop *loop;
+static dbus_bool_t already_quit;
+
+static void
+quit (void)
+{
+ if (!already_quit)
+ {
+ _dbus_loop_quit (loop);
+ already_quit = TRUE;
+ }
+}
static void
die (const char *message)
@@ -62,12 +73,14 @@ filter_func (DBusMessageHandler *handler,
DBusConnection *connection,
DBusMessage *message,
void *user_data)
-{
+{
if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteEcho"))
return handle_echo (connection, message);
- else if (dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
+ else if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteExit") ||
+ dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
{
- _dbus_loop_quit (loop);
+ dbus_connection_disconnect (connection);
+ quit ();
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
else
@@ -85,6 +98,7 @@ main (int argc,
DBusMessageHandler *handler;
const char *to_handle[] = {
"org.freedesktop.DBus.TestSuiteEcho",
+ "org.freedesktop.DBus.TestSuiteExit",
DBUS_MESSAGE_LOCAL_DISCONNECT,
};
int result;
@@ -121,11 +135,13 @@ main (int argc,
fprintf (stderr, "Failed to acquire service: %s\n",
error.message);
dbus_error_free (&error);
- return 1;
+ exit (1);
}
_dbus_loop_run (loop);
+ test_connection_shutdown (loop, connection);
+
dbus_connection_unref (connection);
dbus_message_handler_unref (handler);
@@ -134,6 +150,8 @@ main (int argc,
loop = NULL;
dbus_shutdown ();
+
+ printf ("*** Test service exiting\n");
return 0;
}