2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu" -*- */
|
|
|
|
|
/* dispatch.c Message dispatcher
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 CodeFactory AB
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
* Copyright (C) 2003 Red Hat, Inc.
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
*
|
|
|
|
|
* Licensed under the Academic Free License version 1.2
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "dispatch.h"
|
|
|
|
|
#include "connection.h"
|
|
|
|
|
#include "driver.h"
|
2003-03-13 03:52:58 +00:00
|
|
|
#include "services.h"
|
2003-02-13 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
Add utils.[ch]
* bus/connection.c: (bus_connection_foreach):
Fix a warning.
* bus/desktop-file.c: (grow_lines_in_section), (grow_sections),
(unescape_string), (new_section), (parse_section_start),
(parse_key_value), (report_error), (bus_desktop_file_load),
(bus_desktop_file_get_string):
* bus/desktop-file.h:
Use DBusError for error reporting.
* bus/dispatch.c: (send_one_message),
(bus_dispatch_message_handler):
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_send_service_lost),
(bus_driver_send_service_acquired), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services),
(bus_driver_handle_acquire_service),
(bus_driver_handle_service_exists):
* bus/loop.c: (bus_loop_run):
* bus/main.c:
Use BUS_HANDLE_OOM instead of _DBUS_HANDLE_OOM.
* bus/utils.c: (bus_wait_for_memory):
* bus/utils.h:
New files with general utility functions.
* dbus/dbus-internals.h:
Remove _DBUS_HANDLE_OOM.
2003-02-13 19:06:42 +00:00
|
|
|
#include "utils.h"
|
2003-03-13 03:52:58 +00:00
|
|
|
#include "bus.h"
|
2003-03-14 01:27:58 +00:00
|
|
|
#include "test.h"
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
#include <dbus/dbus-internals.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
static dbus_int32_t message_handler_slot = -1;
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
2003-04-14 02:29:21 +00:00
|
|
|
BusContext *context;
|
|
|
|
|
DBusConnection *sender;
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusMessage *message;
|
|
|
|
|
BusTransaction *transaction;
|
|
|
|
|
DBusError *error;
|
|
|
|
|
} SendMessageData;
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
send_one_message (DBusConnection *connection, void *data)
|
|
|
|
|
{
|
2003-03-13 00:56:43 +00:00
|
|
|
SendMessageData *d = data;
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_context_check_security_policy (d->context,
|
|
|
|
|
d->sender,
|
|
|
|
|
connection,
|
|
|
|
|
d->message,
|
|
|
|
|
NULL))
|
|
|
|
|
return TRUE; /* silently don't send it */
|
|
|
|
|
|
|
|
|
|
if (!bus_transaction_send (d->transaction,
|
|
|
|
|
connection,
|
|
|
|
|
d->message))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (d->error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t
|
|
|
|
|
bus_dispatch_broadcast_message (BusTransaction *transaction,
|
2003-04-14 02:29:21 +00:00
|
|
|
DBusConnection *sender,
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusMessage *message,
|
|
|
|
|
DBusError *error)
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusError tmp_error;
|
|
|
|
|
SendMessageData d;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusConnections *connections;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
_dbus_assert (dbus_message_get_sender (message) != NULL);
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
connections = bus_transaction_get_connections (transaction);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_error_init (&tmp_error);
|
2003-04-14 02:29:21 +00:00
|
|
|
d.sender = sender;
|
|
|
|
|
d.context = bus_transaction_get_context (transaction);
|
2003-03-13 00:56:43 +00:00
|
|
|
d.message = message;
|
|
|
|
|
d.transaction = transaction;
|
|
|
|
|
d.error = &tmp_error;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
bus_connections_foreach_active (connections, send_one_message, &d);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
if (dbus_error_is_set (&tmp_error))
|
|
|
|
|
{
|
|
|
|
|
dbus_move_error (&tmp_error, error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-12 04:15:49 +00:00
|
|
|
static DBusHandlerResult
|
2003-03-14 01:27:58 +00:00
|
|
|
bus_dispatch (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message)
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
2003-02-15 16:25:08 +00:00
|
|
|
const char *sender, *service_name, *message_name;
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusError error;
|
|
|
|
|
BusTransaction *transaction;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusContext *context;
|
2003-08-12 04:15:49 +00:00
|
|
|
DBusHandlerResult result;
|
|
|
|
|
|
|
|
|
|
result = DBUS_HANDLER_RESULT_HANDLED;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
transaction = NULL;
|
|
|
|
|
dbus_error_init (&error);
|
2003-03-17 05:39:10 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
context = bus_connection_get_context (connection);
|
|
|
|
|
_dbus_assert (context != NULL);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* If we can't even allocate an OOM error, we just go to sleep
|
|
|
|
|
* until we can.
|
|
|
|
|
*/
|
|
|
|
|
while (!bus_connection_preallocate_oom_error (connection))
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_wait_for_memory ();
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
/* Ref connection in case we disconnect it at some point in here */
|
|
|
|
|
dbus_connection_ref (connection);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-04-24 19:35:11 +00:00
|
|
|
service_name = dbus_message_get_destination (message);
|
2003-02-15 16:25:08 +00:00
|
|
|
message_name = dbus_message_get_name (message);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (message_name != NULL); /* DBusMessageLoader is supposed to check this */
|
|
|
|
|
|
2003-03-15 02:19:02 +00:00
|
|
|
_dbus_verbose ("DISPATCH: %s to %s\n",
|
|
|
|
|
message_name, service_name ? service_name : "peer");
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
/* If service_name is NULL, this is a message to the bus daemon, not
|
|
|
|
|
* intended to actually go "on the bus"; e.g. a peer-to-peer
|
|
|
|
|
* ping. Handle these immediately, especially disconnection
|
|
|
|
|
* messages. There are no security policy checks on these.
|
2003-03-13 00:56:43 +00:00
|
|
|
*/
|
|
|
|
|
if (service_name == NULL)
|
2003-03-15 02:19:02 +00:00
|
|
|
{
|
2003-03-13 00:56:43 +00:00
|
|
|
if (strcmp (message_name, DBUS_MESSAGE_LOCAL_DISCONNECT) == 0)
|
|
|
|
|
bus_connection_disconnected (connection);
|
|
|
|
|
|
|
|
|
|
/* DBusConnection also handles some of these automatically, we leave
|
|
|
|
|
* it to do so.
|
|
|
|
|
*/
|
2003-08-12 04:15:49 +00:00
|
|
|
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
2003-03-13 00:56:43 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_assert (service_name != NULL); /* this message is intended for bus routing */
|
2003-02-15 16:25:08 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* Create our transaction */
|
2003-03-13 03:52:58 +00:00
|
|
|
transaction = bus_transaction_new (context);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (transaction == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* Assign a sender to the message */
|
|
|
|
|
if (bus_connection_is_active (connection))
|
2003-02-15 16:25:08 +00:00
|
|
|
{
|
2003-03-13 00:56:43 +00:00
|
|
|
sender = bus_connection_get_name (connection);
|
|
|
|
|
_dbus_assert (sender != NULL);
|
2003-03-17 06:49:33 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!dbus_message_set_sender (message, sender))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-03-17 06:49:33 +00:00
|
|
|
|
|
|
|
|
/* We need to refetch the service name here, because
|
|
|
|
|
* dbus_message_set_sender can cause the header to be
|
|
|
|
|
* reallocated, and thus the service_name pointer will become
|
|
|
|
|
* invalid.
|
|
|
|
|
*/
|
2003-04-24 19:35:11 +00:00
|
|
|
service_name = dbus_message_get_destination (message);
|
2003-02-15 16:25:08 +00:00
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
if (strcmp (service_name, DBUS_SERVICE_DBUS) == 0) /* to bus driver */
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_context_check_security_policy (context,
|
|
|
|
|
connection, NULL, message, &error))
|
2003-04-27 06:25:42 +00:00
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Security policy rejected message\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Giving message to %s\n", DBUS_SERVICE_DBUS);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!bus_driver_handle_message (connection, transaction, message, &error))
|
2003-04-27 06:25:42 +00:00
|
|
|
goto out;
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
else if (!bus_connection_is_active (connection)) /* clients must talk to bus driver first */
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Received message from non-registered client. Disconnecting.\n");
|
|
|
|
|
dbus_connection_disconnect (connection);
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
/* FIXME what if we un-special-case this service and just have a flag
|
|
|
|
|
* on services that all service owners will get messages to it, not just
|
|
|
|
|
* the primary owner.
|
|
|
|
|
*/
|
|
|
|
|
else if (strcmp (service_name, DBUS_SERVICE_BROADCAST) == 0) /* spam! */
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_dispatch_broadcast_message (transaction, connection, message, &error))
|
2003-03-13 00:56:43 +00:00
|
|
|
goto out;
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
else /* route to named service */
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
2003-01-27 11:20:55 +00:00
|
|
|
DBusString service_string;
|
|
|
|
|
BusService *service;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusRegistry *registry;
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
registry = bus_connection_get_registry (connection);
|
|
|
|
|
|
2003-01-27 11:20:55 +00:00
|
|
|
_dbus_string_init_const (&service_string, service_name);
|
2003-03-13 03:52:58 +00:00
|
|
|
service = bus_registry_lookup (registry, &service_string);
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (service == NULL)
|
|
|
|
|
{
|
2003-04-14 02:29:21 +00:00
|
|
|
dbus_set_error (&error,
|
|
|
|
|
DBUS_ERROR_SERVICE_DOES_NOT_EXIST,
|
|
|
|
|
"Service \"%s\" does not exist",
|
|
|
|
|
service_name);
|
|
|
|
|
goto out;
|
2003-03-13 00:56:43 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-14 02:29:21 +00:00
|
|
|
DBusConnection *recipient;
|
|
|
|
|
|
|
|
|
|
recipient = bus_service_get_primary_owner (service);
|
|
|
|
|
_dbus_assert (recipient != NULL);
|
|
|
|
|
|
|
|
|
|
if (!bus_context_check_security_policy (context,
|
|
|
|
|
connection, recipient, message, &error))
|
|
|
|
|
goto out;
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* Dispatch the message */
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send (transaction, recipient, message))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
/* If we disconnected it, we won't bother to send it any error
|
|
|
|
|
* messages.
|
|
|
|
|
*/
|
2003-04-27 06:25:42 +00:00
|
|
|
_dbus_verbose ("Not sending error to connection we disconnected\n");
|
2003-03-13 00:56:43 +00:00
|
|
|
}
|
|
|
|
|
else if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
bus_connection_send_oom_error (connection, message);
|
2003-02-16 10:20:04 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* cancel transaction due to OOM */
|
|
|
|
|
if (transaction != NULL)
|
|
|
|
|
{
|
|
|
|
|
bus_transaction_cancel_and_free (transaction);
|
|
|
|
|
transaction = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-16 10:20:04 +00:00
|
|
|
else
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
/* Try to send the real error, if no mem to do that, send
|
|
|
|
|
* the OOM error
|
|
|
|
|
*/
|
|
|
|
|
_dbus_assert (transaction != NULL);
|
|
|
|
|
|
|
|
|
|
if (!bus_transaction_send_error_reply (transaction, connection,
|
|
|
|
|
&error, message))
|
|
|
|
|
{
|
|
|
|
|
bus_connection_send_oom_error (connection, message);
|
2003-04-14 02:29:21 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* cancel transaction due to OOM */
|
|
|
|
|
if (transaction != NULL)
|
|
|
|
|
{
|
|
|
|
|
bus_transaction_cancel_and_free (transaction);
|
|
|
|
|
transaction = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_error_free (&error);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (transaction != NULL)
|
|
|
|
|
{
|
|
|
|
|
bus_transaction_execute_and_free (transaction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
2003-08-12 04:15:49 +00:00
|
|
|
|
|
|
|
|
return result;
|
2003-03-14 01:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static DBusHandlerResult
|
|
|
|
|
bus_dispatch_message_handler (DBusMessageHandler *handler,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
2003-08-12 04:15:49 +00:00
|
|
|
return bus_dispatch (connection, message);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
static void
|
|
|
|
|
free_message_handler (void *data)
|
|
|
|
|
{
|
|
|
|
|
DBusMessageHandler *handler = data;
|
|
|
|
|
|
|
|
|
|
_dbus_assert (message_handler_slot >= 0);
|
|
|
|
|
|
|
|
|
|
dbus_message_handler_unref (handler);
|
2003-06-22 19:39:47 +00:00
|
|
|
dbus_connection_free_data_slot (&message_handler_slot);
|
2003-03-17 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
dbus_bool_t
|
|
|
|
|
bus_dispatch_add_connection (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessageHandler *handler;
|
|
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
if (!dbus_connection_allocate_data_slot (&message_handler_slot))
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
handler = dbus_message_handler_new (bus_dispatch_message_handler, NULL, NULL);
|
2003-03-17 01:54:37 +00:00
|
|
|
if (handler == NULL)
|
|
|
|
|
{
|
2003-06-22 19:39:47 +00:00
|
|
|
dbus_connection_free_data_slot (&message_handler_slot);
|
2003-03-17 01:54:37 +00:00
|
|
|
return FALSE;
|
2003-03-17 05:39:10 +00:00
|
|
|
}
|
2003-03-17 01:54:37 +00:00
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
if (!dbus_connection_add_filter (connection, handler))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_handler_unref (handler);
|
2003-06-22 19:39:47 +00:00
|
|
|
dbus_connection_free_data_slot (&message_handler_slot);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
_dbus_assert (message_handler_slot >= 0);
|
|
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
if (!dbus_connection_set_data (connection,
|
|
|
|
|
message_handler_slot,
|
|
|
|
|
handler,
|
2003-03-17 05:39:10 +00:00
|
|
|
free_message_handler))
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_handler_unref (handler);
|
2003-06-22 19:39:47 +00:00
|
|
|
dbus_connection_free_data_slot (&message_handler_slot);
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_dispatch_remove_connection (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
/* Here we tell the bus driver that we want to get off. */
|
|
|
|
|
bus_driver_remove_connection (connection);
|
2003-01-27 11:20:55 +00:00
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
dbus_connection_set_data (connection,
|
|
|
|
|
message_handler_slot,
|
|
|
|
|
NULL, NULL);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
}
|
2003-03-14 01:27:58 +00:00
|
|
|
|
|
|
|
|
#ifdef DBUS_BUILD_TESTS
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
typedef dbus_bool_t (* Check1Func) (BusContext *context);
|
|
|
|
|
typedef dbus_bool_t (* Check2Func) (BusContext *context,
|
|
|
|
|
DBusConnection *connection);
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
static dbus_bool_t check_no_leftovers (BusContext *context);
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
static void
|
|
|
|
|
block_connection_until_message_from_bus (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
while (dbus_connection_get_dispatch_status (connection) ==
|
|
|
|
|
DBUS_DISPATCH_COMPLETE &&
|
|
|
|
|
dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
bus_test_run_bus_loop (context, TRUE);
|
|
|
|
|
bus_test_run_clients_loop (FALSE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* compensate for fact that pop_message() can return #NULL due to OOM */
|
|
|
|
|
static DBusMessage*
|
|
|
|
|
pop_message_waiting_for_memory (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
while (dbus_connection_get_dispatch_status (connection) ==
|
|
|
|
|
DBUS_DISPATCH_NEED_MEMORY)
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
|
|
|
|
|
return dbus_connection_pop_message (connection);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char *expected_service_name;
|
|
|
|
|
dbus_bool_t failed;
|
|
|
|
|
} CheckServiceDeletedData;
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_service_deleted_foreach (DBusConnection *connection,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
CheckServiceDeletedData *d = data;
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusError error;
|
|
|
|
|
char *service_name;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
d->failed = TRUE;
|
|
|
|
|
service_name = NULL;
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a message on %p, expecting %s\n",
|
|
|
|
|
connection, DBUS_MESSAGE_SERVICE_DELETED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
else if (!dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_DELETED))
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Received message %s on %p, expecting %s\n",
|
|
|
|
|
dbus_message_get_name (message),
|
|
|
|
|
connection, DBUS_MESSAGE_SERVICE_DELETED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("no memory to get service name arg\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Did not get the expected single string argument\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp (service_name, d->expected_service_name) != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("expected deletion of service %s, got deletion of %s\n",
|
|
|
|
|
d->expected_service_name,
|
|
|
|
|
service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d->failed = FALSE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_free (service_name);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return !d->failed;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
static void
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
kill_client_connection (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
char *base_service;
|
|
|
|
|
const char *s;
|
|
|
|
|
CheckServiceDeletedData csdd;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("killing connection %p\n", connection);
|
|
|
|
|
|
|
|
|
|
s = dbus_bus_get_base_service (connection);
|
|
|
|
|
_dbus_assert (s != NULL);
|
|
|
|
|
|
|
|
|
|
while ((base_service = _dbus_strdup (s)) == NULL)
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_wait_for_memory ();
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
|
|
|
|
dbus_connection_ref (connection);
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
/* kick in the disconnect handler that unrefs the connection */
|
|
|
|
|
dbus_connection_disconnect (connection);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
2003-04-04 00:39:22 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
_dbus_assert (bus_test_client_listed (connection));
|
|
|
|
|
|
|
|
|
|
/* Run disconnect handler in test.c */
|
2003-03-16 20:16:47 +00:00
|
|
|
if (bus_connection_dispatch_one_message (connection))
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
_dbus_assert_not_reached ("something received on connection being killed other than the disconnect");
|
|
|
|
|
|
|
|
|
|
_dbus_assert (!dbus_connection_get_is_connected (connection));
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
connection = NULL;
|
|
|
|
|
_dbus_assert (!bus_test_client_listed (connection));
|
|
|
|
|
|
|
|
|
|
csdd.expected_service_name = base_service;
|
|
|
|
|
csdd.failed = FALSE;
|
|
|
|
|
|
|
|
|
|
bus_test_clients_foreach (check_service_deleted_foreach,
|
|
|
|
|
&csdd);
|
|
|
|
|
|
|
|
|
|
dbus_free (base_service);
|
|
|
|
|
|
|
|
|
|
if (csdd.failed)
|
|
|
|
|
_dbus_assert_not_reached ("didn't get the expected ServiceDeleted messages");
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
_dbus_assert_not_reached ("stuff left in message queues after disconnecting a client");
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
static void
|
|
|
|
|
kill_client_connection_unchecked (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
/* This kills the connection without expecting it to affect
|
|
|
|
|
* the rest of the bus.
|
|
|
|
|
*/
|
|
|
|
|
_dbus_verbose ("Unchecked kill of connection %p\n", connection);
|
|
|
|
|
|
|
|
|
|
dbus_connection_ref (connection);
|
|
|
|
|
dbus_connection_disconnect (connection);
|
|
|
|
|
/* dispatching disconnect handler will unref once */
|
|
|
|
|
if (bus_connection_dispatch_one_message (connection))
|
|
|
|
|
_dbus_assert_not_reached ("message other than disconnect dispatched after failure to register");
|
2003-04-14 02:29:21 +00:00
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
_dbus_assert (!bus_test_client_listed (connection));
|
2003-04-14 02:29:21 +00:00
|
|
|
dbus_connection_unref (connection);
|
2003-03-17 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
dbus_bool_t failed;
|
|
|
|
|
} CheckNoMessagesData;
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_no_messages_foreach (DBusConnection *connection,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
CheckNoMessagesData *d = data;
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (message != NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Received message %s on %p, expecting no messages\n",
|
|
|
|
|
dbus_message_get_name (message), connection);
|
|
|
|
|
d->failed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return !d->failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *skip_connection;
|
|
|
|
|
const char *expected_service_name;
|
|
|
|
|
dbus_bool_t failed;
|
|
|
|
|
} CheckServiceCreatedData;
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_service_created_foreach (DBusConnection *connection,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
CheckServiceCreatedData *d = data;
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusError error;
|
|
|
|
|
char *service_name;
|
|
|
|
|
|
|
|
|
|
if (connection == d->skip_connection)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
d->failed = TRUE;
|
|
|
|
|
service_name = NULL;
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a message on %p, expecting %s\n",
|
|
|
|
|
connection, DBUS_MESSAGE_SERVICE_CREATED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
else if (!dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_CREATED))
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Received message %s on %p, expecting %s\n",
|
|
|
|
|
dbus_message_get_name (message),
|
|
|
|
|
connection, DBUS_MESSAGE_SERVICE_CREATED);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("no memory to get service name arg\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Did not get the expected single string argument\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (strcmp (service_name, d->expected_service_name) != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("expected creation of service %s, got creation of %s\n",
|
|
|
|
|
d->expected_service_name,
|
|
|
|
|
service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d->failed = FALSE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_free (service_name);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return !d->failed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_no_leftovers (BusContext *context)
|
|
|
|
|
{
|
|
|
|
|
CheckNoMessagesData nmd;
|
|
|
|
|
|
|
|
|
|
nmd.failed = FALSE;
|
|
|
|
|
bus_test_clients_foreach (check_no_messages_foreach,
|
|
|
|
|
&nmd);
|
|
|
|
|
|
|
|
|
|
if (nmd.failed)
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
return TRUE;
|
2003-03-15 06:00:01 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-15 02:19:02 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
2003-03-14 01:27:58 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
check_hello_message (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_int32_t serial;
|
2003-03-15 06:00:01 +00:00
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
char *name;
|
|
|
|
|
char *acquired;
|
2003-04-14 02:29:21 +00:00
|
|
|
|
|
|
|
|
retval = FALSE;
|
2003-03-15 06:00:01 +00:00
|
|
|
dbus_error_init (&error);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
name = NULL;
|
|
|
|
|
acquired = NULL;
|
2003-04-14 02:29:21 +00:00
|
|
|
message = NULL;
|
2003-03-14 01:27:58 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_MESSAGE_HELLO,
|
|
|
|
|
DBUS_SERVICE_DBUS);
|
2003-03-14 01:27:58 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
2003-03-15 02:19:02 +00:00
|
|
|
return TRUE;
|
2003-03-14 01:27:58 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
2003-03-17 05:39:10 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-03-15 02:19:02 +00:00
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
2003-03-15 06:00:01 +00:00
|
|
|
message = NULL;
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
/* send our message */
|
|
|
|
|
bus_test_run_clients_loop (TRUE);
|
|
|
|
|
|
|
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
|
|
|
|
block_connection_until_message_from_bus (context, connection);
|
2003-03-14 01:27:58 +00:00
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected\n");
|
2003-04-18 17:45:34 +00:00
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-04-14 02:29:21 +00:00
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-03-15 02:19:02 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
DBUS_MESSAGE_HELLO, serial, connection);
|
2003-03-15 06:00:01 +00:00
|
|
|
goto out;
|
2003-03-15 02:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Received %s on %p\n",
|
|
|
|
|
dbus_message_get_name (message), connection);
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect error %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
CheckServiceCreatedData scd;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message,
|
|
|
|
|
DBUS_MESSAGE_HELLO))
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
|
|
|
|
; /* good, expected */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect reply %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
retry_get_hello_name:
|
2003-03-15 06:00:01 +00:00
|
|
|
if (!dbus_message_get_args (message, &error,
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
DBUS_TYPE_STRING, &name,
|
2003-03-15 06:00:01 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("no memory to get service name arg from hello\n");
|
|
|
|
|
dbus_error_free (&error);
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_wait_for_memory ();
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
goto retry_get_hello_name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Did not get the expected single string argument to hello\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Got hello name: %s\n", name);
|
|
|
|
|
|
|
|
|
|
while (!dbus_bus_set_base_service (connection, name))
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_wait_for_memory ();
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
|
|
|
|
scd.skip_connection = NULL;
|
|
|
|
|
scd.failed = FALSE;
|
|
|
|
|
scd.expected_service_name = name;
|
|
|
|
|
bus_test_clients_foreach (check_service_created_foreach,
|
|
|
|
|
&scd);
|
|
|
|
|
|
|
|
|
|
if (scd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Client should also have gotten ServiceAcquired */
|
|
|
|
|
dbus_message_unref (message);
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expecting %s, got nothing\n",
|
|
|
|
|
DBUS_MESSAGE_SERVICE_ACQUIRED);
|
2003-03-15 06:00:01 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
|
|
|
|
retry_get_acquired_name:
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &acquired,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("no memory to get service name arg from acquired\n");
|
|
|
|
|
dbus_error_free (&error);
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_wait_for_memory ();
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
goto retry_get_acquired_name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Did not get the expected single string argument to ServiceAcquired\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Got acquired name: %s\n", acquired);
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (strcmp (acquired, name) != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Acquired name is %s but expected %s\n",
|
|
|
|
|
acquired, name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-03-15 06:00:01 +00:00
|
|
|
}
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
goto out;
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
retval = TRUE;
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
out:
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
dbus_free (name);
|
|
|
|
|
dbus_free (acquired);
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_hello_connection (BusContext *context)
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection;
|
2003-03-25 04:37:08 +00:00
|
|
|
DBusError error;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-25 04:37:08 +00:00
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
connection = dbus_connection_open ("debug-pipe:name=test-server", &error);
|
2003-03-15 06:00:01 +00:00
|
|
|
if (connection == NULL)
|
|
|
|
|
{
|
2003-03-25 04:37:08 +00:00
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (&error);
|
|
|
|
|
dbus_error_free (&error);
|
2003-03-15 06:00:01 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bus_setup_debug_client (connection))
|
|
|
|
|
{
|
2003-03-15 20:47:16 +00:00
|
|
|
dbus_connection_disconnect (connection);
|
2003-03-15 06:00:01 +00:00
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_hello_message (context, connection))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (dbus_bus_get_base_service (connection) == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* We didn't successfully register, so we can't
|
|
|
|
|
* do the usual kill_client_connection() checks
|
|
|
|
|
*/
|
2003-03-17 05:39:10 +00:00
|
|
|
kill_client_connection_unchecked (connection);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
kill_client_connection (context, connection);
|
|
|
|
|
}
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-02 20:14:52 +00:00
|
|
|
#define NONEXISTENT_SERVICE_NAME "test.this.service.does.not.exist.ewuoiurjdfxcvn"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_nonexistent_service_activation (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_int32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE,
|
|
|
|
|
DBUS_SERVICE_DBUS);
|
2003-04-02 20:14:52 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_append_args (message,
|
|
|
|
|
DBUS_TYPE_STRING, NONEXISTENT_SERVICE_NAME,
|
|
|
|
|
DBUS_TYPE_UINT32, 0,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
block_connection_until_message_from_bus (context, connection);
|
2003-04-04 00:39:22 +00:00
|
|
|
bus_test_run_everything (context);
|
2003-04-02 20:14:52 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected\n");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-04-02 20:14:52 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE, serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Received %s on %p\n",
|
|
|
|
|
dbus_message_get_name (message), connection);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
2003-04-24 21:26:25 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
else if (dbus_message_has_name (message,
|
|
|
|
|
DBUS_ERROR_ACTIVATE_SERVICE_NOT_FOUND))
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect error %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully activate %s\n",
|
|
|
|
|
NONEXISTENT_SERVICE_NAME);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-07 23:28:16 +00:00
|
|
|
static dbus_bool_t
|
2003-04-10 01:15:28 +00:00
|
|
|
check_base_service_activated (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
DBusMessage *initial_message,
|
|
|
|
|
char **base_service_p)
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
char *base_service;
|
|
|
|
|
|
|
|
|
|
base_service = NULL;
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
message = initial_message;
|
2003-04-10 01:15:28 +00:00
|
|
|
dbus_message_ref (message);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_CREATED))
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
|
|
|
|
char *service_name;
|
|
|
|
|
CheckServiceCreatedData scd;
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
reget_service_name_arg:
|
2003-04-07 23:28:16 +00:00
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
2003-04-10 05:12:19 +00:00
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
goto reget_service_name_arg;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message %s doesn't have a service name: %s\n",
|
|
|
|
|
dbus_message_get_name (message),
|
|
|
|
|
error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
if (*service_name != ':')
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
2003-04-10 01:15:28 +00:00
|
|
|
_dbus_warn ("Expected base service activation, got \"%s\" instead\n",
|
|
|
|
|
service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
base_service = service_name;
|
|
|
|
|
service_name = NULL;
|
|
|
|
|
|
|
|
|
|
scd.skip_connection = connection;
|
|
|
|
|
scd.failed = FALSE;
|
|
|
|
|
scd.expected_service_name = base_service;
|
|
|
|
|
bus_test_clients_foreach (check_service_created_foreach,
|
|
|
|
|
&scd);
|
|
|
|
|
|
|
|
|
|
if (scd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-10 05:12:19 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected to get base service ServiceCreated, instead got %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
retval = TRUE;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
if (base_service_p)
|
|
|
|
|
{
|
|
|
|
|
*base_service_p = base_service;
|
|
|
|
|
base_service = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
if (base_service)
|
|
|
|
|
dbus_free (base_service);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_service_activated (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *activated_name,
|
|
|
|
|
const char *base_service_name,
|
|
|
|
|
DBusMessage *initial_message)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
dbus_uint32_t activation_result;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
message = initial_message;
|
|
|
|
|
dbus_message_ref (message);
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_CREATED))
|
2003-04-10 01:15:28 +00:00
|
|
|
{
|
|
|
|
|
char *service_name;
|
|
|
|
|
CheckServiceCreatedData scd;
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
reget_service_name_arg:
|
2003-04-10 01:15:28 +00:00
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
2003-04-10 05:12:19 +00:00
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
goto reget_service_name_arg;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message %s doesn't have a service name: %s\n",
|
|
|
|
|
dbus_message_get_name (message),
|
|
|
|
|
error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp (service_name, activated_name) != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected to see service %s created, saw %s instead\n",
|
|
|
|
|
activated_name, service_name);
|
|
|
|
|
dbus_free (service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scd.skip_connection = connection;
|
|
|
|
|
scd.failed = FALSE;
|
|
|
|
|
scd.expected_service_name = service_name;
|
|
|
|
|
bus_test_clients_foreach (check_service_created_foreach,
|
|
|
|
|
&scd);
|
|
|
|
|
|
|
|
|
|
dbus_free (service_name);
|
|
|
|
|
|
|
|
|
|
if (scd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-04-07 23:28:16 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected a reply to %s, got nothing\n",
|
|
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-10 05:12:19 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected to get service %s ServiceCreated, instead got %s\n",
|
|
|
|
|
activated_name, dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (!dbus_message_has_name (message, DBUS_MESSAGE_ACTIVATE_SERVICE))
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected reply to %s, got message %s instead\n",
|
|
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE,
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activation_result = 0;
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_UINT32, &activation_result,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not have activation result first argument to %s: %s\n",
|
|
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE, error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (activation_result == DBUS_ACTIVATION_REPLY_ACTIVATED)
|
|
|
|
|
; /* Good */
|
|
|
|
|
else if (activation_result == DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE)
|
|
|
|
|
; /* Good also */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Activation result was 0x%x, no good.\n",
|
|
|
|
|
activation_result);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Messages were left over after verifying existent activation results\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_service_deactivated (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *activated_name,
|
|
|
|
|
const char *base_service)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
CheckServiceDeletedData csdd;
|
|
|
|
|
|
|
|
|
|
message = NULL;
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
/* Now we are expecting ServiceDeleted messages for the base
|
|
|
|
|
* service and the activated_name. The base service
|
2003-04-09 20:31:21 +00:00
|
|
|
* notification is required to come last.
|
2003-04-07 23:28:16 +00:00
|
|
|
*/
|
|
|
|
|
csdd.expected_service_name = activated_name;
|
|
|
|
|
csdd.failed = FALSE;
|
|
|
|
|
bus_test_clients_foreach (check_service_deleted_foreach,
|
|
|
|
|
&csdd);
|
|
|
|
|
|
|
|
|
|
if (csdd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
csdd.expected_service_name = base_service;
|
|
|
|
|
csdd.failed = FALSE;
|
|
|
|
|
bus_test_clients_foreach (check_service_deleted_foreach,
|
|
|
|
|
&csdd);
|
|
|
|
|
|
|
|
|
|
if (csdd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Messages were left over after verifying results of service exiting\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-09 20:31:21 +00:00
|
|
|
|
|
|
|
|
retval = TRUE;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
check_send_exit_to_service (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *service_name,
|
|
|
|
|
const char *base_service)
|
|
|
|
|
{
|
|
|
|
|
dbus_bool_t got_error;
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_int32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Sending exit message to the test service\n");
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
/* Kill off the test service by sending it a quit message */
|
2003-08-11 02:11:58 +00:00
|
|
|
message = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteExit",
|
|
|
|
|
service_name);
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* Do this again; we still need the service to exit... */
|
|
|
|
|
if (!check_send_exit_to_service (context, connection,
|
|
|
|
|
service_name, base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
/* Do this again; we still need the service to exit... */
|
|
|
|
|
if (!check_send_exit_to_service (context, connection,
|
|
|
|
|
service_name, base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
/* send message */
|
|
|
|
|
bus_test_run_clients_loop (TRUE);
|
|
|
|
|
|
|
|
|
|
/* read it in and write it out to test service */
|
|
|
|
|
bus_test_run_bus_loop (context, FALSE);
|
|
|
|
|
|
|
|
|
|
/* see if we got an error during message bus dispatching */
|
|
|
|
|
bus_test_run_clients_loop (FALSE);
|
|
|
|
|
message = dbus_connection_borrow_message (connection);
|
2003-08-11 02:11:58 +00:00
|
|
|
got_error = message != NULL && dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR;
|
2003-04-10 05:12:19 +00:00
|
|
|
if (message)
|
2003-04-14 02:29:21 +00:00
|
|
|
{
|
|
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
}
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
if (!got_error)
|
|
|
|
|
{
|
|
|
|
|
/* If no error, wait for the test service to exit */
|
|
|
|
|
block_connection_until_message_from_bus (context, connection);
|
|
|
|
|
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (got_error)
|
|
|
|
|
{
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
_dbus_assert (message != NULL);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
|
2003-04-10 05:12:19 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("expecting an error reply to asking test service to exit, got %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
else if (!dbus_message_has_name (message, DBUS_ERROR_NO_MEMORY))
|
2003-04-10 05:12:19 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("not expecting error %s when asking test service to exit\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Got error %s when asking test service to exit\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
|
|
|
|
|
/* Do this again; we still need the service to exit... */
|
|
|
|
|
if (!check_send_exit_to_service (context, connection,
|
|
|
|
|
service_name, base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!check_service_deactivated (context, connection,
|
|
|
|
|
service_name, base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
check_got_error (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
2003-04-11 03:58:56 +00:00
|
|
|
const char *first_error_name,
|
|
|
|
|
...)
|
2003-04-11 00:03:06 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
2003-04-11 03:58:56 +00:00
|
|
|
va_list ap;
|
|
|
|
|
dbus_bool_t error_found;
|
|
|
|
|
const char *error_name;
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not get an expected error\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
|
2003-04-11 00:03:06 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected an error, got %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 03:58:56 +00:00
|
|
|
error_found = FALSE;
|
|
|
|
|
|
|
|
|
|
va_start (ap, first_error_name);
|
|
|
|
|
error_name = first_error_name;
|
|
|
|
|
while (error_name != NULL)
|
|
|
|
|
{
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message, error_name))
|
2003-04-11 03:58:56 +00:00
|
|
|
{
|
|
|
|
|
error_found = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
error_name = va_arg (ap, char*);
|
|
|
|
|
}
|
|
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
|
|
if (!error_found)
|
2003-04-11 00:03:06 +00:00
|
|
|
{
|
2003-04-11 03:58:56 +00:00
|
|
|
_dbus_warn ("Expected error %s or other, got %s instead\n",
|
|
|
|
|
first_error_name,
|
2003-04-11 00:03:06 +00:00
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-04 00:39:22 +00:00
|
|
|
#define EXISTENT_SERVICE_NAME "org.freedesktop.DBus.TestSuiteEchoService"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_existent_service_activation (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_int32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
2003-04-07 23:28:16 +00:00
|
|
|
char *base_service;
|
|
|
|
|
|
|
|
|
|
base_service = NULL;
|
2003-04-04 00:39:22 +00:00
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE,
|
|
|
|
|
DBUS_SERVICE_DBUS);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_append_args (message,
|
|
|
|
|
DBUS_TYPE_STRING, EXISTENT_SERVICE_NAME,
|
|
|
|
|
DBUS_TYPE_UINT32, 0,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
/* now wait for the message bus to hear back from the activated
|
|
|
|
|
* service.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection);
|
|
|
|
|
|
2003-04-04 00:39:22 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected\n");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-04-04 00:39:22 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
2003-04-10 01:15:28 +00:00
|
|
|
_dbus_warn ("Did not receive any messages after %s %d on %p\n",
|
2003-04-04 00:39:22 +00:00
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE, serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
_dbus_verbose ("Received %s on %p after sending %s\n",
|
|
|
|
|
dbus_message_get_name (message), connection,
|
|
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
2003-04-04 00:39:22 +00:00
|
|
|
{
|
2003-04-24 21:26:25 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2003-04-04 00:39:22 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-04-04 00:39:22 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
else if (dbus_message_has_name (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_EXITED))
|
2003-04-09 20:31:21 +00:00
|
|
|
{
|
2003-04-11 03:45:40 +00:00
|
|
|
; /* good, this is expected also */
|
2003-04-09 20:31:21 +00:00
|
|
|
}
|
2003-04-04 00:39:22 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect error %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-10 01:15:28 +00:00
|
|
|
dbus_bool_t got_service_deleted;
|
2003-04-11 00:03:06 +00:00
|
|
|
dbus_bool_t got_error;
|
2003-04-10 01:15:28 +00:00
|
|
|
|
|
|
|
|
if (!check_base_service_activated (context, connection,
|
|
|
|
|
message, &base_service))
|
2003-04-07 23:28:16 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
2003-04-10 01:15:28 +00:00
|
|
|
|
|
|
|
|
/* We may need to block here for the test service to exit or finish up */
|
2003-04-10 05:12:19 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
message = dbus_connection_borrow_message (connection);
|
2003-04-07 23:28:16 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
2003-04-10 01:15:28 +00:00
|
|
|
_dbus_warn ("Did not receive any messages after base service creation notification\n");
|
|
|
|
|
goto out;
|
2003-04-07 23:28:16 +00:00
|
|
|
}
|
2003-04-10 01:15:28 +00:00
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
got_service_deleted = dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_DELETED);
|
2003-08-11 02:11:58 +00:00
|
|
|
got_error = dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR;
|
2003-04-11 00:03:06 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
2003-04-11 00:03:06 +00:00
|
|
|
|
|
|
|
|
if (got_error)
|
|
|
|
|
{
|
|
|
|
|
if (!check_got_error (context, connection,
|
2003-04-11 03:58:56 +00:00
|
|
|
DBUS_ERROR_SPAWN_CHILD_EXITED,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY,
|
|
|
|
|
NULL))
|
2003-04-11 00:03:06 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* A service deleted should be coming along now after this error.
|
|
|
|
|
* We can also get the error *after* the service deleted.
|
|
|
|
|
*/
|
|
|
|
|
got_service_deleted = TRUE;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
if (got_service_deleted)
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
2003-04-10 01:15:28 +00:00
|
|
|
/* The service started up and got a base address, but then
|
|
|
|
|
* failed to register under EXISTENT_SERVICE_NAME
|
|
|
|
|
*/
|
|
|
|
|
CheckServiceDeletedData csdd;
|
|
|
|
|
|
|
|
|
|
csdd.expected_service_name = base_service;
|
|
|
|
|
csdd.failed = FALSE;
|
|
|
|
|
bus_test_clients_foreach (check_service_deleted_foreach,
|
|
|
|
|
&csdd);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
if (csdd.failed)
|
|
|
|
|
goto out;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
/* Now we should get an error about the service exiting
|
|
|
|
|
* if we didn't get it before.
|
|
|
|
|
*/
|
|
|
|
|
if (!got_error)
|
2003-04-10 01:15:28 +00:00
|
|
|
{
|
2003-04-11 00:03:06 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection);
|
|
|
|
|
|
|
|
|
|
/* and process everything again */
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!check_got_error (context, connection,
|
2003-04-11 03:58:56 +00:00
|
|
|
DBUS_ERROR_SPAWN_CHILD_EXITED,
|
|
|
|
|
NULL))
|
2003-04-11 00:03:06 +00:00
|
|
|
goto out;
|
2003-04-10 01:15:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-04-10 05:12:19 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
2003-04-10 01:15:28 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message we just put back! should have been a ServiceCreated\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_service_activated (context, connection, EXISTENT_SERVICE_NAME,
|
|
|
|
|
base_service, message))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Messages were left over after successful activation\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
if (!check_send_exit_to_service (context, connection,
|
|
|
|
|
EXISTENT_SERVICE_NAME, base_service))
|
|
|
|
|
goto out;
|
2003-04-10 01:15:28 +00:00
|
|
|
}
|
2003-04-04 00:39:22 +00:00
|
|
|
}
|
2003-04-11 03:45:40 +00:00
|
|
|
|
2003-04-04 00:39:22 +00:00
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
if (base_service)
|
|
|
|
|
dbus_free (base_service);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 03:45:40 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_segfault_service_activation (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_int32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE,
|
|
|
|
|
DBUS_SERVICE_DBUS);
|
2003-04-11 03:45:40 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_append_args (message,
|
|
|
|
|
DBUS_TYPE_STRING,
|
|
|
|
|
"org.freedesktop.DBus.TestSuiteSegfaultService",
|
|
|
|
|
DBUS_TYPE_UINT32, 0,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
block_connection_until_message_from_bus (context, connection);
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected\n");
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
DBUS_MESSAGE_ACTIVATE_SERVICE, serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Received %s on %p\n",
|
|
|
|
|
dbus_message_get_name (message), connection);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
2003-04-11 03:45:40 +00:00
|
|
|
{
|
2003-04-24 21:26:25 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2003-04-11 03:45:40 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (dbus_message_has_name (message,
|
2003-04-11 03:45:40 +00:00
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
else if (dbus_message_has_name (message,
|
2003-04-11 03:45:40 +00:00
|
|
|
DBUS_ERROR_SPAWN_CHILD_SIGNALED))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect error %s\n",
|
|
|
|
|
dbus_message_get_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully activate segfault service\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
typedef struct
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
2003-03-28 05:42:19 +00:00
|
|
|
Check1Func func;
|
|
|
|
|
BusContext *context;
|
|
|
|
|
} Check1Data;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
check_oom_check1_func (void *data)
|
|
|
|
|
{
|
|
|
|
|
Check1Data *d = data;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
if (! (* d->func) (d->context))
|
|
|
|
|
return FALSE;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
if (!check_no_leftovers (d->context))
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
2003-04-07 23:28:16 +00:00
|
|
|
_dbus_warn ("Messages were left over, should be covered by test suite\n");
|
2003-03-28 05:42:19 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
static void
|
|
|
|
|
check1_try_iterations (BusContext *context,
|
|
|
|
|
const char *description,
|
|
|
|
|
Check1Func func)
|
|
|
|
|
{
|
|
|
|
|
Check1Data d;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
d.func = func;
|
|
|
|
|
d.context = context;
|
2003-03-17 05:39:10 +00:00
|
|
|
|
2003-03-28 05:42:19 +00:00
|
|
|
if (!_dbus_test_oom_handling (description, check_oom_check1_func,
|
|
|
|
|
&d))
|
|
|
|
|
_dbus_assert_not_reached ("test failed");
|
2003-03-15 06:00:01 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-02 20:14:52 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
Check2Func func;
|
|
|
|
|
BusContext *context;
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
} Check2Data;
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_oom_check2_func (void *data)
|
|
|
|
|
{
|
|
|
|
|
Check2Data *d = data;
|
|
|
|
|
|
|
|
|
|
if (! (* d->func) (d->context, d->connection))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (d->context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Messages were left over, should be covered by test suite");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check2_try_iterations (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *description,
|
|
|
|
|
Check2Func func)
|
|
|
|
|
{
|
|
|
|
|
Check2Data d;
|
|
|
|
|
|
|
|
|
|
d.func = func;
|
|
|
|
|
d.context = context;
|
|
|
|
|
d.connection = connection;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_test_oom_handling (description, check_oom_check2_func,
|
|
|
|
|
&d))
|
|
|
|
|
_dbus_assert_not_reached ("test failed");
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
dbus_bool_t
|
|
|
|
|
bus_dispatch_test (const DBusString *test_data_dir)
|
|
|
|
|
{
|
|
|
|
|
BusContext *context;
|
|
|
|
|
DBusConnection *foo;
|
|
|
|
|
DBusConnection *bar;
|
|
|
|
|
DBusConnection *baz;
|
2003-03-31 08:19:50 +00:00
|
|
|
DBusError error;
|
2003-04-14 23:52:40 +00:00
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
2003-03-31 08:19:50 +00:00
|
|
|
|
|
|
|
|
context = bus_context_new_test (test_data_dir,
|
|
|
|
|
"valid-config-files/debug-allow-all.conf");
|
|
|
|
|
if (context == NULL)
|
|
|
|
|
return FALSE;
|
2003-03-14 01:27:58 +00:00
|
|
|
|
2003-03-25 04:37:08 +00:00
|
|
|
foo = dbus_connection_open ("debug-pipe:name=test-server", &error);
|
2003-03-14 01:27:58 +00:00
|
|
|
if (foo == NULL)
|
|
|
|
|
_dbus_assert_not_reached ("could not alloc connection");
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (!bus_setup_debug_client (foo))
|
|
|
|
|
_dbus_assert_not_reached ("could not set up connection");
|
|
|
|
|
|
|
|
|
|
if (!check_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
|
|
|
|
|
2003-03-25 04:37:08 +00:00
|
|
|
bar = dbus_connection_open ("debug-pipe:name=test-server", &error);
|
2003-03-14 01:27:58 +00:00
|
|
|
if (bar == NULL)
|
|
|
|
|
_dbus_assert_not_reached ("could not alloc connection");
|
|
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (!bus_setup_debug_client (bar))
|
|
|
|
|
_dbus_assert_not_reached ("could not set up connection");
|
|
|
|
|
|
|
|
|
|
if (!check_hello_message (context, bar))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
|
|
|
|
|
2003-03-25 04:37:08 +00:00
|
|
|
baz = dbus_connection_open ("debug-pipe:name=test-server", &error);
|
2003-03-14 01:27:58 +00:00
|
|
|
if (baz == NULL)
|
|
|
|
|
_dbus_assert_not_reached ("could not alloc connection");
|
2003-03-15 04:25:09 +00:00
|
|
|
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
if (!bus_setup_debug_client (baz))
|
2003-03-15 04:25:09 +00:00
|
|
|
_dbus_assert_not_reached ("could not set up connection");
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
2003-03-15 02:19:02 +00:00
|
|
|
if (!check_hello_message (context, baz))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Messages were left over after setting up initial connections");
|
|
|
|
|
_dbus_assert_not_reached ("initial connection setup failed");
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-17 20:25:33 +00:00
|
|
|
check1_try_iterations (context, "create_and_hello",
|
2003-04-11 03:45:40 +00:00
|
|
|
check_hello_connection);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2003-04-02 20:14:52 +00:00
|
|
|
check2_try_iterations (context, foo, "nonexistent_service_activation",
|
|
|
|
|
check_nonexistent_service_activation);
|
|
|
|
|
|
2003-04-11 03:45:40 +00:00
|
|
|
check2_try_iterations (context, foo, "segfault_service_activation",
|
|
|
|
|
check_segfault_service_activation);
|
|
|
|
|
|
|
|
|
|
check2_try_iterations (context, foo, "existent_service_activation",
|
|
|
|
|
check_existent_service_activation);
|
2003-03-17 03:09:31 +00:00
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
_dbus_verbose ("Disconnecting foo, bar, and baz\n");
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
kill_client_connection_unchecked (foo);
|
|
|
|
|
kill_client_connection_unchecked (bar);
|
|
|
|
|
kill_client_connection_unchecked (baz);
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
|
|
|
|
|
bus_context_unref (context);
|
2003-03-14 01:27:58 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-04-14 23:52:40 +00:00
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_dispatch_sha1_test (const DBusString *test_data_dir)
|
|
|
|
|
{
|
|
|
|
|
BusContext *context;
|
|
|
|
|
DBusConnection *foo;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
/* Test SHA1 authentication */
|
|
|
|
|
_dbus_verbose ("Testing SHA1 context\n");
|
|
|
|
|
|
|
|
|
|
context = bus_context_new_test (test_data_dir,
|
2003-04-18 05:52:11 +00:00
|
|
|
"valid-config-files/debug-allow-all-sha1.conf");
|
2003-04-14 23:52:40 +00:00
|
|
|
if (context == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
foo = dbus_connection_open ("debug-pipe:name=test-server", &error);
|
|
|
|
|
if (foo == NULL)
|
|
|
|
|
_dbus_assert_not_reached ("could not alloc connection");
|
|
|
|
|
|
|
|
|
|
if (!bus_setup_debug_client (foo))
|
|
|
|
|
_dbus_assert_not_reached ("could not set up connection");
|
|
|
|
|
|
|
|
|
|
if (!check_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
2003-04-18 17:45:34 +00:00
|
|
|
_dbus_warn ("Messages were left over after setting up initial SHA-1 connection\n");
|
2003-04-14 23:52:40 +00:00
|
|
|
_dbus_assert_not_reached ("initial connection setup failed");
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-17 20:25:33 +00:00
|
|
|
check1_try_iterations (context, "create_and_hello_sha1",
|
2003-04-14 23:52:40 +00:00
|
|
|
check_hello_connection);
|
|
|
|
|
|
|
|
|
|
kill_client_connection_unchecked (foo);
|
|
|
|
|
|
|
|
|
|
bus_context_unref (context);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
#endif /* DBUS_BUILD_TESTS */
|