summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2004-04-21 22:13:07 +0000
committerKristian Høgsberg <krh@redhat.com>2004-04-21 22:13:07 +0000
commit6971a06b04b3fdd48b61202b2276e8140f4b7be0 (patch)
treeafff44ba475c63c2c3c03c53d4be9886d94dbea9 /dbus
parentdd8b1b1d654c983ccc040b59143a11f239de0726 (diff)
2004-04-21 Kristian Høgsberg <krh@redhat.com>
* dbus/dbus-server-unix.c (unix_finalize): Don't unref unix_server->watch here, it is unreffed in disconnect. (_dbus_server_new_for_tcp_socket): convert NULL host to "localhost" here so we don't append NULL to address. * dbus/dbus-server.c (_dbus_server_test): Add test case for various addresses, including tcp with no explicit host.
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-server-unix.c6
-rw-r--r--dbus/dbus-server.c39
-rw-r--r--dbus/dbus-sysdeps.c3
-rw-r--r--dbus/dbus-test.c6
-rw-r--r--dbus/dbus-test.h1
5 files changed, 49 insertions, 6 deletions
diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c
index e0400290..a1d7b4ce 100644
--- a/dbus/dbus-server-unix.c
+++ b/dbus/dbus-server-unix.c
@@ -59,9 +59,6 @@ unix_finalize (DBusServer *server)
{
DBusServerUnix *unix_server = (DBusServerUnix*) server;
- if (unix_server->watch)
- _dbus_watch_unref (unix_server->watch);
-
dbus_free (unix_server->socket_name);
_dbus_server_finalize_base (server);
@@ -368,6 +365,9 @@ _dbus_server_new_for_tcp_socket (const char *host,
return NULL;
}
+ if (host == NULL)
+ host = "localhost";
+
if (!_dbus_string_append (&address, "tcp:host=") ||
!_dbus_string_append (&address, host) ||
!_dbus_string_append (&address, ",port=") ||
diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c
index 339f8360..2fa52ebe 100644
--- a/dbus/dbus-server.c
+++ b/dbus/dbus-server.c
@@ -788,3 +788,42 @@ dbus_server_get_data (DBusServer *server,
/** @} */
+#ifdef DBUS_BUILD_TESTS
+#include "dbus-test.h"
+
+dbus_bool_t
+_dbus_server_test (void)
+{
+ const char *valid_addresses[] = {
+ "tcp:port=1234",
+ "unix:path=./boogie",
+ "tcp:host=localhost,port=1234",
+ "tcp:host=localhost,port=1234;tcp:port=5678",
+ "tcp:port=1234;unix:path=./boogie",
+ };
+
+ DBusServer *server;
+ int i;
+
+ for (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++)
+ {
+ server = dbus_server_listen (valid_addresses[i], NULL);
+ if (server == NULL)
+ _dbus_assert_not_reached ("Failed to listen for valid address.");
+
+ dbus_server_unref (server);
+
+ /* Try disconnecting before unreffing */
+ server = dbus_server_listen (valid_addresses[i], NULL);
+ if (server == NULL)
+ _dbus_assert_not_reached ("Failed to listen for valid address.");
+
+ dbus_server_disconnect (server);
+
+ dbus_server_unref (server);
+ }
+
+ return TRUE;
+}
+
+#endif /* DBUS_BUILD_TESTS */
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 9c06ce80..e9d00201 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -687,9 +687,6 @@ _dbus_listen_tcp_socket (const char *host,
return -1;
}
- if (host == NULL)
- host = "localhost";
-
he = gethostbyname (host);
if (he == NULL)
{
diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c
index 36482301..9fd035d0 100644
--- a/dbus/dbus-test.c
+++ b/dbus/dbus-test.c
@@ -100,6 +100,12 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir)
check_memleaks ();
+ printf ("%s: running server listen tests\n", "dbus-test");
+ if (!_dbus_server_test ())
+ die ("server listen");
+
+ check_memleaks ();
+
printf ("%s: running object tree tests\n", "dbus-test");
if (!_dbus_object_tree_test ())
die ("object tree");
diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h
index cc75b721..df3b2845 100644
--- a/dbus/dbus-test.h
+++ b/dbus/dbus-test.h
@@ -42,6 +42,7 @@ dbus_bool_t _dbus_marshal_test (void);
dbus_bool_t _dbus_mem_pool_test (void);
dbus_bool_t _dbus_string_test (void);
dbus_bool_t _dbus_address_test (void);
+dbus_bool_t _dbus_server_test (void);
dbus_bool_t _dbus_message_test (const char *test_data_dir);
dbus_bool_t _dbus_auth_test (const char *test_data_dir);
dbus_bool_t _dbus_md5_test (void);