Commit 6971a06b authored by Kristian Høgsberg's avatar Kristian Høgsberg

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.
parent dd8b1b1d
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.
2004-04-21 Olivier Andrieu <oliv__a@users.sourceforge.net>
* dbus/dbus-message.c (decode_header_data, decode_string_field):
......
......@@ -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=") ||
......
......@@ -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 */
......@@ -687,9 +687,6 @@ _dbus_listen_tcp_socket (const char *host,
return -1;
}
if (host == NULL)
host = "localhost";
he = gethostbyname (host);
if (he == NULL)
{
......
......@@ -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");
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment