2007-07-14 02:44:01 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
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
|
|
|
/* dispatch.c Message dispatcher
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 CodeFactory AB
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
* Copyright (C) 2003, 2004, 2005 Red Hat, Inc.
|
2004-03-16 18:00:35 +00:00
|
|
|
* Copyright (C) 2004 Imendio HB
|
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
|
|
|
*
|
2004-08-10 03:07:01 +00:00
|
|
|
* Licensed under the Academic Free License version 2.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
|
|
|
*
|
|
|
|
|
* 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
|
2009-07-10 19:32:38 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
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 "dispatch.h"
|
|
|
|
|
#include "connection.h"
|
|
|
|
|
#include "driver.h"
|
2003-03-13 03:52:58 +00:00
|
|
|
#include "services.h"
|
2004-03-16 18:00:35 +00:00
|
|
|
#include "activation.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-09-21 19:53:56 +00:00
|
|
|
#include "signals.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-03-13 00:56:43 +00:00
|
|
|
static dbus_bool_t
|
2003-09-21 19:53:56 +00:00
|
|
|
send_one_message (DBusConnection *connection,
|
|
|
|
|
BusContext *context,
|
|
|
|
|
DBusConnection *sender,
|
|
|
|
|
DBusConnection *addressed_recipient,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
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-10-14 05:16:56 +00:00
|
|
|
if (!bus_context_check_security_policy (context, transaction,
|
2003-09-21 19:53:56 +00:00
|
|
|
sender,
|
|
|
|
|
addressed_recipient,
|
2003-04-14 02:29:21 +00:00
|
|
|
connection,
|
2003-09-21 19:53:56 +00:00
|
|
|
message,
|
2003-04-14 02:29:21 +00:00
|
|
|
NULL))
|
|
|
|
|
return TRUE; /* silently don't send it */
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
if (!bus_transaction_send (transaction,
|
2003-04-14 02:29:21 +00:00
|
|
|
connection,
|
2003-09-21 19:53:56 +00:00
|
|
|
message))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
2003-09-21 19:53:56 +00:00
|
|
|
BUS_SET_OOM (error);
|
2003-03-13 00:56:43 +00:00
|
|
|
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
|
2003-09-21 19:53:56 +00:00
|
|
|
bus_dispatch_matches (BusTransaction *transaction,
|
|
|
|
|
DBusConnection *sender,
|
|
|
|
|
DBusConnection *addressed_recipient,
|
|
|
|
|
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;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusConnections *connections;
|
2003-09-21 19:53:56 +00:00
|
|
|
DBusList *recipients;
|
|
|
|
|
BusMatchmaker *matchmaker;
|
|
|
|
|
DBusList *link;
|
|
|
|
|
BusContext *context;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
/* sender and recipient can both be NULL for the bus driver,
|
|
|
|
|
* or for signals with no particular recipient
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
_dbus_assert (sender == NULL || bus_connection_is_active (sender));
|
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-09-21 19:53:56 +00:00
|
|
|
context = bus_transaction_get_context (transaction);
|
|
|
|
|
matchmaker = bus_context_get_matchmaker (context);
|
|
|
|
|
|
|
|
|
|
recipients = NULL;
|
2004-09-24 10:43:36 +00:00
|
|
|
if (!bus_matchmaker_get_recipients (matchmaker, connections,
|
2003-09-21 19:53:56 +00:00
|
|
|
sender, addressed_recipient, message,
|
|
|
|
|
&recipients))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_get_first_link (&recipients);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *dest;
|
|
|
|
|
|
|
|
|
|
dest = link->data;
|
|
|
|
|
|
|
|
|
|
if (!send_one_message (dest, context, sender, addressed_recipient,
|
|
|
|
|
message, transaction, &tmp_error))
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_get_next_link (&recipients, link);
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
_dbus_list_clear (&recipients);
|
|
|
|
|
|
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-08-18 15:27:33 +00:00
|
|
|
const char *sender, *service_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;
|
2003-09-21 19:53:56 +00:00
|
|
|
DBusConnection *addressed_recipient;
|
|
|
|
|
|
2003-08-12 04:15:49 +00:00
|
|
|
result = DBUS_HANDLER_RESULT_HANDLED;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
transaction = NULL;
|
2003-09-21 19:53:56 +00:00
|
|
|
addressed_recipient = NULL;
|
2003-03-13 00:56:43 +00:00
|
|
|
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-08-18 15:27:33 +00:00
|
|
|
|
2003-04-24 19:35:11 +00:00
|
|
|
service_name = dbus_message_get_destination (message);
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-08-18 15:27:33 +00:00
|
|
|
#ifdef DBUS_ENABLE_VERBOSE_MODE
|
|
|
|
|
{
|
|
|
|
|
const char *interface_name, *member_name, *error_name;
|
|
|
|
|
|
|
|
|
|
interface_name = dbus_message_get_interface (message);
|
|
|
|
|
member_name = dbus_message_get_member (message);
|
|
|
|
|
error_name = dbus_message_get_error_name (message);
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("DISPATCH: %s %s %s to %s\n",
|
|
|
|
|
interface_name ? interface_name : "(no interface)",
|
|
|
|
|
member_name ? member_name : "(no member)",
|
|
|
|
|
error_name ? error_name : "(no error name)",
|
|
|
|
|
service_name ? service_name : "peer");
|
|
|
|
|
}
|
|
|
|
|
#endif /* DBUS_ENABLE_VERBOSE_MODE */
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
/* If service_name is NULL, if it's a signal we send it to all
|
2003-10-21 05:46:52 +00:00
|
|
|
* connections with a match rule. If it's not a signal, there
|
|
|
|
|
* are some special cases here but mostly we just bail out.
|
2003-03-13 00:56:43 +00:00
|
|
|
*/
|
|
|
|
|
if (service_name == NULL)
|
2003-09-21 19:53:56 +00:00
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_LOCAL,
|
2003-08-18 22:43:30 +00:00
|
|
|
"Disconnected"))
|
2003-09-21 19:53:56 +00:00
|
|
|
{
|
|
|
|
|
bus_connection_disconnected (connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_SIGNAL)
|
|
|
|
|
{
|
|
|
|
|
/* DBusConnection also handles some of these automatically, we leave
|
|
|
|
|
* it to do so.
|
|
|
|
|
*/
|
|
|
|
|
result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-03-13 00:56:43 +00:00
|
|
|
}
|
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-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
if (service_name &&
|
2005-02-17 21:19:49 +00:00
|
|
|
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-10-14 05:16:56 +00:00
|
|
|
if (!bus_context_check_security_policy (context, transaction,
|
2003-09-21 19:53:56 +00:00
|
|
|
connection, NULL, NULL, message, &error))
|
2003-04-27 06:25:42 +00:00
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Security policy rejected message\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
_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");
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (connection);
|
2003-09-21 19:53:56 +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-09-21 19:53:56 +00:00
|
|
|
else if (service_name != NULL) /* 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-09-21 19:53:56 +00:00
|
|
|
_dbus_assert (service_name != NULL);
|
|
|
|
|
|
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
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
if (service == NULL && dbus_message_get_auto_start (message))
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
2005-07-14 20:44:15 +00:00
|
|
|
BusActivation *activation;
|
|
|
|
|
/* We can't do the security policy check here, since the addressed
|
|
|
|
|
* recipient service doesn't exist yet. We do it before sending the
|
|
|
|
|
* message after the service has been created.
|
|
|
|
|
*/
|
|
|
|
|
activation = bus_connection_get_activation (connection);
|
|
|
|
|
|
|
|
|
|
if (!bus_activation_activate_service (activation, connection, transaction, TRUE,
|
|
|
|
|
message, service_name, &error))
|
|
|
|
|
{
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (&error);
|
2005-09-11 10:02:47 +00:00
|
|
|
_dbus_verbose ("bus_activation_activate_service() failed: %s\n", error.name);
|
2005-07-14 20:44:15 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2004-03-16 18:00:35 +00:00
|
|
|
else if (service == NULL)
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
2003-04-14 02:29:21 +00:00
|
|
|
dbus_set_error (&error,
|
2005-01-18 20:42:15 +00:00
|
|
|
DBUS_ERROR_NAME_HAS_NO_OWNER,
|
|
|
|
|
"Name \"%s\" does not exist",
|
2003-04-14 02:29:21 +00:00
|
|
|
service_name);
|
|
|
|
|
goto out;
|
2003-03-13 00:56:43 +00:00
|
|
|
}
|
|
|
|
|
else
|
2005-07-14 20:44:15 +00:00
|
|
|
{
|
* configure.in: Add test/name-test/Makefile to the generated
Makefile list
* dbus/dbus-shared.h (#define DBUS_NAME_FLAG_ALLOW_REPLACEMENT):
New flag which replaces DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT
(#define DBUS_NAME_FLAG_DO_NOT_QUEUE): New flag for specifying
not to queue an ower if it can't be the primary owner
* bus/bus.h: Add new internal BusOwner struct
* bus/driver.c (bus_driver_handle_hello): Send flags (0 for default)
to bus_registry_ensure and don't set the prohibit_replacement flag
since they are now set per BusOwner and not per name.
(bus_driver_handle_list_queued_owners): bus method (ListQueuedOwners)
that returns the list of connections in a name's connection queue
* bus/services.c (struct BusService): remove prohibit_replacement field
(struct BusOwner): new struct for keeping track of queued connections
and their associated flags for the queue
(struct BusRegistry): add a BusOwner memory pool
(bus_registry_new): initialize the BusOwner memory pool
(bus_registry_unref): free the BusOwner memory pool
(_bus_service_find_owner_link): new internal method for
searching the queue for a specific connection
(bus_owner_set_flags): new method for adding setting the flags on a
bus owner
(bus_owner_new): new method that creates a BusOwner object from the
pool and sets its flags
(bus_owner_ref, bus_owner_unref): ref counting for BusOwner objects
(bus_registry_ensure): Add the flags parameter
(bus_registry_acquire_service): Switch from using raw connections to
using the BusOwner struct
Add new state machine for dealing with the new set of flags
(bus_registry_set_service_context_table, struct OwnershipCancelData,
cancel_ownership, free_ownership_cancel_data,
add_cancel_ownership_to_transaction, struct OwnershipRestoreData,
restore_ownership, free_ownership_restore_data,
add_restore_ownership_to_transaction): Switch to using BusOwner
instead of raw connections
(bus_service_add_owner): Add flags parameter
Switch to using BusOwner instead of raw connections
Add state machine for dealing with the new set of flags
(bus_service_swap_owner): Swaps the first and second owners in the
queue. Used to make sure proper signals are sent when a service looses
or gains primary ownership. We never insert an owner at the top of the
queue. Instead we insert it in the second position and then swap.
(bus_service_remove_owner): Remove the owner from the queue sending
out the NameLost and NameOwnerChanged signals if the we were the
primary owner
(bus_service_get_primary_owners_connection): New method that extracts
the connection from the primary owner
(bus_service_get_primary_owner): Returns the BusOwner instead of the
connection
(bus_service_get_allow_replacement): Changed from the old
bus_service_get_prohibit_replacement method. Checks the flags of the
primary owner and returns if it can be replaced or not
(bus_service_set_prohibit_replacement): removed
(bus_service_has_owner): returns TRUE if and owner with
the specified connection exists in the queue
* dbus/dbus-bus.c (dbus_bus_connection_get_unique_name): New helper
method that only compiles if tests are enabled. Allows us to get the
unique name of a connection so we can check it against the queue when
doing regression tests
* bus/activation.c (bus_activation_send_pending_auto_activate),
bus/dispatch.c (bus_dispatch),
bus/driver.c (bus_driver_handle_get_service_owner,
bus_driver_handle_get_connection_unix_user,
bus_driver_handle_get_connection_unix_process_id,
bus_driver_handle_get_connection_selinux_security_context),
bus/signals.c (connection_is_primary_owner):
use bus_service_get_primary_owners_connection instead of
bus_service_get_primary_owner
* dbus/dbus-sysdeps.c (_dbus_connect_unix_socket,
_dbus_listen_unix_socket): Calculate the length of the socket
path and use that instead of using a fixed length which was
causing socket names to contain many trailing Nul bytes.
* dbus/dbus-glib-lowlevel.h, glib/dbus-gobject.c
(dbus_g_method_get_sender): New method for extracting the sender
from a DBusGMethodInvocation
(dbus_g_method_return_get_reply): changed name to
dbus_g_method_get_reply
(dbus_g_method_return_send_reply): changed name to
dbus_g_method_send reply
* doc/dbus-specification.xml: New docs that describe how the new
queueing system works and talks about the changes to the how
we specify socket names
* glib/examples/example-service.c,
glib/examples/example-signal-emitter.c,
glib/examples/statemachine/statemachine-server.c:
Changed the RequestName flags to the new system
* test/name-test/ (test-names.c, run-test.sh, Makefile.am): New
regression test suite for testing various states of the new
queueing system
2005-11-22 20:37:00 +00:00
|
|
|
addressed_recipient = bus_service_get_primary_owners_connection (service);
|
2003-09-21 19:53:56 +00:00
|
|
|
_dbus_assert (addressed_recipient != NULL);
|
2003-04-14 02:29:21 +00:00
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
if (!bus_context_check_security_policy (context, transaction,
|
2003-09-21 19:53:56 +00:00
|
|
|
connection, addressed_recipient,
|
|
|
|
|
addressed_recipient,
|
|
|
|
|
message, &error))
|
2003-04-14 02:29:21 +00:00
|
|
|
goto out;
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* Dispatch the message */
|
2003-09-21 19:53:56 +00:00
|
|
|
if (!bus_transaction_send (transaction, addressed_recipient, message))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
/* Now match the messages against any match rules, which will send
|
|
|
|
|
* out signals and such. addressed_recipient may == NULL.
|
|
|
|
|
*/
|
|
|
|
|
if (!bus_dispatch_matches (transaction, connection, addressed_recipient, message, &error))
|
|
|
|
|
goto out;
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-14 20:44:15 +00:00
|
|
|
|
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
|
2003-08-31 03:25:24 +00:00
|
|
|
bus_dispatch_message_filter (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
void *user_data)
|
2003-03-14 01:27:58 +00:00
|
|
|
{
|
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-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)
|
2003-08-31 03:25:24 +00:00
|
|
|
{
|
|
|
|
|
if (!dbus_connection_add_filter (connection,
|
|
|
|
|
bus_dispatch_message_filter,
|
|
|
|
|
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
|
|
|
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
|
|
|
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-08-31 03:25:24 +00:00
|
|
|
dbus_connection_remove_filter (connection,
|
|
|
|
|
bus_dispatch_message_filter,
|
|
|
|
|
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
|
|
|
|
|
|
2004-03-16 18:00:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
/* This is used to know whether we need to block in order to finish
|
|
|
|
|
* sending a message, or whether the initial dbus_connection_send()
|
|
|
|
|
* already flushed the queue.
|
|
|
|
|
*/
|
|
|
|
|
#define SEND_PENDING(connection) (dbus_connection_has_messages_to_send (connection))
|
|
|
|
|
|
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,
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *what_is_expected)
|
2003-04-10 05:12:19 +00:00
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("expecting: %s\n", what_is_expected);
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
static void
|
|
|
|
|
spin_connection_until_authenticated (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Spinning to auth connection %p\n", connection);
|
|
|
|
|
while (!dbus_connection_get_is_authenticated (connection) &&
|
|
|
|
|
dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
bus_test_run_bus_loop (context, FALSE);
|
|
|
|
|
bus_test_run_clients_loop (FALSE);
|
|
|
|
|
}
|
|
|
|
|
_dbus_verbose (" ... done spinning to auth connection %p\n", connection);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-31 09:15:24 +00:00
|
|
|
static DBusMessage*
|
|
|
|
|
borrow_message_waiting_for_memory (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
while (dbus_connection_get_dispatch_status (connection) ==
|
|
|
|
|
DBUS_DISPATCH_NEED_MEMORY)
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
|
|
|
|
|
return dbus_connection_borrow_message (connection);
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
static void
|
2003-08-20 14:48:04 +00:00
|
|
|
warn_unexpected_real (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message,
|
|
|
|
|
const char *expected,
|
|
|
|
|
const char *function,
|
|
|
|
|
int line)
|
2003-08-18 22:43:30 +00:00
|
|
|
{
|
2003-10-28 23:51:24 +00:00
|
|
|
if (message)
|
|
|
|
|
_dbus_warn ("%s:%d received message interface \"%s\" member \"%s\" error name \"%s\" on %p, expecting %s\n",
|
|
|
|
|
function, line,
|
|
|
|
|
dbus_message_get_interface (message) ?
|
|
|
|
|
dbus_message_get_interface (message) : "(unset)",
|
|
|
|
|
dbus_message_get_member (message) ?
|
|
|
|
|
dbus_message_get_member (message) : "(unset)",
|
|
|
|
|
dbus_message_get_error_name (message) ?
|
|
|
|
|
dbus_message_get_error_name (message) : "(unset)",
|
|
|
|
|
connection,
|
|
|
|
|
expected);
|
|
|
|
|
else
|
|
|
|
|
_dbus_warn ("%s:%d received no message on %p, expecting %s\n",
|
|
|
|
|
function, line, connection, expected);
|
2003-08-18 22:43:30 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-20 14:48:04 +00:00
|
|
|
#define warn_unexpected(connection, message, expected) \
|
|
|
|
|
warn_unexpected_real (connection, message, expected, _DBUS_FUNCTION_NAME, __LINE__)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
verbose_message_received (DBusConnection *connection,
|
|
|
|
|
DBusMessage *message)
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Received message interface \"%s\" member \"%s\" error name \"%s\" on %p\n",
|
|
|
|
|
dbus_message_get_interface (message) ?
|
|
|
|
|
dbus_message_get_interface (message) : "(unset)",
|
|
|
|
|
dbus_message_get_member (message) ?
|
|
|
|
|
dbus_message_get_member (message) : "(unset)",
|
|
|
|
|
dbus_message_get_error_name (message) ?
|
|
|
|
|
dbus_message_get_error_name (message) : "(unset)",
|
|
|
|
|
connection);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
SERVICE_CREATED,
|
|
|
|
|
OWNER_CHANGED,
|
|
|
|
|
SERVICE_DELETED
|
|
|
|
|
} ServiceInfoKind;
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
ServiceInfoKind expected_kind;
|
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
|
|
|
const char *expected_service_name;
|
|
|
|
|
dbus_bool_t failed;
|
2004-09-24 10:43:36 +00:00
|
|
|
DBusConnection *skip_connection;
|
|
|
|
|
} CheckServiceOwnerChangedData;
|
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
|
2004-09-24 10:43:36 +00:00
|
|
|
check_service_owner_changed_foreach (DBusConnection *connection,
|
2005-07-14 20:44:15 +00:00
|
|
|
void *data)
|
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
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData *d = data;
|
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
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusError error;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *service_name, *old_owner, *new_owner;
|
2004-09-24 10:43:36 +00:00
|
|
|
|
|
|
|
|
if (d->expected_kind == SERVICE_CREATED
|
|
|
|
|
&& connection == d->skip_connection)
|
|
|
|
|
return TRUE;
|
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_init (&error);
|
|
|
|
|
d->failed = TRUE;
|
|
|
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
connection, "NameOwnerChanged");
|
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 out;
|
|
|
|
|
}
|
2003-08-18 22:43:30 +00:00
|
|
|
else if (!dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged"))
|
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
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
warn_unexpected (connection, message, "NameOwnerChanged");
|
2003-08-18 22:43:30 +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
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
reget_service_info_data:
|
|
|
|
|
service_name = NULL;
|
|
|
|
|
old_owner = NULL;
|
|
|
|
|
new_owner = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
|
|
|
|
DBUS_TYPE_STRING, &old_owner,
|
|
|
|
|
DBUS_TYPE_STRING, &new_owner,
|
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
|
|
|
|
|
if (dbus_error_is_set (&error))
|
2005-07-14 20:44:15 +00:00
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
dbus_error_free (&error);
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
goto reget_service_info_data;
|
2005-07-14 20:44:15 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not get the expected arguments\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
|
|
|
|
|
if ((d->expected_kind == SERVICE_CREATED && ( old_owner[0] || !new_owner[0]))
|
|
|
|
|
|| (d->expected_kind == OWNER_CHANGED && (!old_owner[0] || !new_owner[0]))
|
|
|
|
|
|| (d->expected_kind == SERVICE_DELETED && (!old_owner[0] || new_owner[0])))
|
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
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("inconsistent NameOwnerChanged arguments\n");
|
2004-09-24 10:43:36 +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
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
|
|
|
|
|
if (strcmp (service_name, d->expected_service_name) != 0)
|
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
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
_dbus_warn ("expected info on service %s, got info on %s\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
|
|
|
d->expected_service_name,
|
|
|
|
|
service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
|
|
|
|
|
if (*service_name == ':' && new_owner[0]
|
|
|
|
|
&& strcmp (service_name, new_owner) != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("inconsistent ServiceOwnedChanged message (\"%s\" [ %s -> %s ])\n",
|
|
|
|
|
service_name, old_owner, new_owner);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d->failed = FALSE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return !d->failed;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
|
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;
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData socd;
|
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_verbose ("killing connection %p\n", connection);
|
|
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
s = dbus_bus_get_unique_name (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 (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 */
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (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));
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
socd.expected_kind = SERVICE_DELETED;
|
|
|
|
|
socd.expected_service_name = base_service;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = NULL;
|
|
|
|
|
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
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_free (base_service);
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
if (socd.failed)
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_assert_not_reached ("didn't get the expected NameOwnerChanged (deletion) messages");
|
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))
|
|
|
|
|
_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);
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (connection);
|
2003-03-17 05:39:10 +00:00
|
|
|
/* 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)
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message, "no messages");
|
|
|
|
|
|
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
|
|
|
d->failed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
{
|
|
|
|
|
_dbus_verbose ("%s: leftover message found\n",
|
|
|
|
|
_DBUS_FUNCTION_NAME);
|
|
|
|
|
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
|
|
|
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;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBusMessage *name_message;
|
2003-09-21 19:53:56 +00:00
|
|
|
dbus_uint32_t serial;
|
2003-03-15 06:00:01 +00:00
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *name;
|
|
|
|
|
const 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;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
name_message = NULL;
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("check_hello_message for %p\n", connection);
|
2003-03-14 01:27:58 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2003-08-31 01:51:44 +00:00
|
|
|
"Hello");
|
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
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
|
|
|
|
|
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);
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
dbus_connection_unref (connection);
|
2003-03-17 05:39:10 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_assert (dbus_message_has_signature (message, ""));
|
|
|
|
|
|
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
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected (presumably auth failed)\n");
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
/* send our message */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
2003-04-14 02:29:21 +00:00
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected (presumably auth failed)\n");
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to Hello");
|
2003-03-14 01:27:58 +00:00
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected (presumably auth failed)\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",
|
2003-08-18 22:43:30 +00:00
|
|
|
"Hello", serial, connection);
|
2003-03-15 06:00:01 +00:00
|
|
|
goto out;
|
2003-03-15 02:19:02 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-20 14:48:04 +00:00
|
|
|
verbose_message_received (connection, message);
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2005-02-17 21:19:49 +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-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_error (message,
|
2003-04-24 21:26:25 +00:00
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData socd;
|
2003-03-15 06:00:01 +00:00
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
2003-03-15 06:00:01 +00:00
|
|
|
{
|
|
|
|
|
; /* good, expected */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message, "method return for Hello");
|
|
|
|
|
|
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_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);
|
|
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
while (!dbus_bus_set_unique_name (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
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
socd.expected_kind = SERVICE_CREATED;
|
|
|
|
|
socd.expected_service_name = name;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = connection; /* we haven't done AddMatch so won't get it ourselves */
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
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
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
if (socd.failed)
|
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 out;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
|
|
|
|
|
name_message = message;
|
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
|
|
|
/* Client should also have gotten ServiceAcquired */
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameAcquired");
|
2003-03-15 06:00:01 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2005-02-17 21:19:49 +00:00
|
|
|
if (! dbus_message_is_signal (message, DBUS_INTERFACE_DBUS,
|
2005-07-14 20:44:15 +00:00
|
|
|
"NameAcquired"))
|
2004-09-24 10:43:36 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expecting %s, got smthg else\n",
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameAcquired");
|
2004-09-24 10:43:36 +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;
|
|
|
|
|
}
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
acquired = NULL;
|
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:
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
_dbus_verbose ("ending %s retval = %d\n", _DBUS_FUNCTION_NAME, retval);
|
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
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
dbus_error_free (&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
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
|
|
|
|
|
if (name_message)
|
|
|
|
|
dbus_message_unref (name_message);
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-17 09:14:49 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_double_hello_message (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("check_double_hello_message for %p\n", connection);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2004-09-17 09:14:49 +00:00
|
|
|
"Hello");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
2005-01-21 03:44:10 +00:00
|
|
|
|
2004-09-17 09:14:49 +00:00
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
/* send our message */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
2004-09-17 09:14:49 +00:00
|
|
|
|
|
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to Hello");
|
2004-09-17 09:14:49 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2004-09-17 09:14:49 +00:00
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
"Hello", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2004-09-17 09:14:49 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "method return for Hello");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-28 21:55:15 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_get_connection_unix_user (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
const char *base_service_name;
|
|
|
|
|
dbus_uint32_t uid;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("check_get_connection_unix_user for %p\n", connection);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2004-06-28 21:55:15 +00:00
|
|
|
"GetConnectionUnixUser");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
base_service_name = dbus_bus_get_unique_name (connection);
|
2004-06-28 21:55:15 +00:00
|
|
|
|
|
|
|
|
if (!dbus_message_append_args (message,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &base_service_name,
|
2004-06-28 21:55:15 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* send our message */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
2004-06-28 21:55:15 +00:00
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to GetConnectionUnixUser");
|
2004-06-28 21:55:15 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2004-06-28 21:55:15 +00:00
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
"GetConnectionUnixUser", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_is_error (message, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
|
|
|
|
{
|
|
|
|
|
; /* good, expected */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message,
|
2005-07-14 20:44:15 +00:00
|
|
|
"method_return for GetConnectionUnixUser");
|
2004-06-28 21:55:15 +00:00
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retry_get_property:
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_UINT32, &uid,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
2004-07-19 20:55:58 +00:00
|
|
|
_dbus_verbose ("no memory to get uid by GetConnectionUnixUser\n");
|
2004-06-28 21:55:15 +00:00
|
|
|
dbus_error_free (&error);
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
goto retry_get_property;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
2004-07-19 20:55:58 +00:00
|
|
|
_dbus_warn ("Did not get the expected DBUS_TYPE_UINT32 from GetConnectionUnixUser\n");
|
2004-06-28 21:55:15 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_get_connection_unix_process_id (BusContext *context,
|
2005-07-14 20:44:15 +00:00
|
|
|
DBusConnection *connection)
|
2004-07-19 20:55:58 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
const char *base_service_name;
|
|
|
|
|
dbus_uint32_t pid;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("check_get_connection_unix_process_id for %p\n", connection);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2004-07-19 20:55:58 +00:00
|
|
|
"GetConnectionUnixProcessID");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
base_service_name = dbus_bus_get_unique_name (connection);
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
if (!dbus_message_append_args (message,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &base_service_name,
|
2004-07-19 20:55:58 +00:00
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* send our message */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to GetConnectionUnixProcessID");
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
"GetConnectionUnixProcessID", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_is_error (message, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2007-06-14 22:02:10 +00:00
|
|
|
#ifdef DBUS_WIN
|
|
|
|
|
else if (dbus_message_is_error (message, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN))
|
|
|
|
|
{
|
|
|
|
|
/* We are expecting this error, since we know in the test suite we aren't
|
|
|
|
|
* talking to a client running on UNIX
|
|
|
|
|
*/
|
|
|
|
|
_dbus_verbose ("Windows correctly does not support GetConnectionUnixProcessID\n");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2004-07-19 20:55:58 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
2007-06-14 22:02:10 +00:00
|
|
|
|
2004-07-19 20:55:58 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-06-14 22:02:10 +00:00
|
|
|
#ifdef DBUS_WIN
|
|
|
|
|
warn_unexpected (connection, message, "GetConnectionUnixProcessID to fail on Windows");
|
|
|
|
|
goto out;
|
|
|
|
|
#else
|
2004-07-19 20:55:58 +00:00
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
|
|
|
|
{
|
|
|
|
|
; /* good, expected */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message,
|
2005-07-14 20:44:15 +00:00
|
|
|
"method_return for GetConnectionUnixProcessID");
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retry_get_property:
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_UINT32, &pid,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("no memory to get pid by GetConnectionUnixProcessID\n");
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
goto retry_get_property;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Did not get the expected DBUS_TYPE_UINT32 from GetConnectionUnixProcessID\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2007-06-14 22:02:10 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-07-14 20:44:15 +00:00
|
|
|
/* test if returned pid is the same as our own pid
|
|
|
|
|
*
|
|
|
|
|
* @todo It would probably be good to restructure the tests
|
|
|
|
|
* in a way so our parent is the bus that we're testing
|
|
|
|
|
* cause then we can test that the pid returned matches
|
|
|
|
|
* getppid()
|
|
|
|
|
*/
|
2007-06-14 22:02:10 +00:00
|
|
|
if (pid != (dbus_uint32_t) _dbus_getpid ())
|
2005-07-14 20:44:15 +00:00
|
|
|
{
|
2004-07-19 20:55:58 +00:00
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Result from GetConnectionUnixProcessID is not our own pid\n");
|
|
|
|
|
goto out;
|
2005-07-14 20:44:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-06-14 22:02:10 +00:00
|
|
|
#endif /* !DBUS_WIN */
|
2004-07-19 20:55:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_add_match_all (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
DBusError error;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *empty = "";
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("check_add_match_all for %p\n", connection);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2003-09-21 19:53:56 +00:00
|
|
|
"AddMatch");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2003-10-10 02:42:21 +00:00
|
|
|
/* empty string match rule matches everything */
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &empty,
|
2003-09-21 19:53:56 +00:00
|
|
|
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;
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
/* send our message */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
2003-09-21 19:53:56 +00:00
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to AddMatch");
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
"AddMatch", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2003-09-21 19:53:56 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
|
|
|
|
{
|
|
|
|
|
; /* good, expected */
|
|
|
|
|
_dbus_assert (dbus_message_get_reply_serial (message) == serial);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "method return for AddMatch");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
/* 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);
|
|
|
|
|
|
2006-10-01 15:36:19 +00:00
|
|
|
connection = dbus_connection_open_private ("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))
|
|
|
|
|
{
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (connection);
|
2003-03-15 06:00:01 +00:00
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
spin_connection_until_authenticated (context, connection);
|
|
|
|
|
|
2003-03-15 06:00:01 +00:00
|
|
|
if (!check_hello_message (context, connection))
|
|
|
|
|
return FALSE;
|
2003-09-21 19:53:56 +00:00
|
|
|
|
2005-01-18 20:42:15 +00:00
|
|
|
if (dbus_bus_get_unique_name (connection) == 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
|
|
|
{
|
|
|
|
|
/* 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
|
|
|
|
|
{
|
2003-09-21 19:53:56 +00:00
|
|
|
if (!check_add_match_all (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
|
|
|
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
|
2005-01-21 03:44:10 +00:00
|
|
|
check_nonexistent_service_no_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
2003-09-21 19:53:56 +00:00
|
|
|
dbus_uint32_t serial;
|
2003-04-02 20:14:52 +00:00
|
|
|
dbus_bool_t retval;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *nonexistent = NONEXISTENT_SERVICE_NAME;
|
|
|
|
|
dbus_uint32_t flags;
|
2003-04-02 20:14:52 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName");
|
|
|
|
|
|
2003-04-02 20:14:52 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2005-01-21 03:44:10 +00:00
|
|
|
dbus_message_set_auto_start (message, FALSE);
|
|
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
flags = 0;
|
2003-04-02 20:14:52 +00:00
|
|
|
if (!dbus_message_append_args (message,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &nonexistent,
|
|
|
|
|
DBUS_TYPE_UINT32, &flags,
|
2003-04-02 20:14:52 +00:00
|
|
|
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);
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to ActivateService on nonexistent");
|
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))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2003-04-02 20:14:52 +00:00
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName", serial, connection);
|
2003-04-02 20:14:52 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-20 14:48:04 +00:00
|
|
|
verbose_message_received (connection, message);
|
2003-04-02 20:14:52 +00:00
|
|
|
|
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
|
|
|
{
|
2005-02-17 21:19:49 +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-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_error (message,
|
2003-04-24 21:26:25 +00:00
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2003-08-18 22:43:30 +00:00
|
|
|
else if (dbus_message_is_error (message,
|
2005-01-18 20:42:15 +00:00
|
|
|
DBUS_ERROR_SERVICE_UNKNOWN))
|
2003-04-02 20:14:52 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message, "not this error");
|
2003-04-02 20:14:52 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 18:00:35 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
2005-01-21 03:44:10 +00:00
|
|
|
check_nonexistent_service_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (NONEXISTENT_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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);
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to Echo");
|
2004-03-16 18:00:35 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2004-03-16 18:00:35 +00:00
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
2005-01-18 20:42:15 +00:00
|
|
|
DBUS_ERROR_SERVICE_UNKNOWN))
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
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,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char **base_service_p)
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *base_service, *base_service_from_bus, *old_owner;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
2004-09-24 10:43:36 +00:00
|
|
|
base_service = NULL;
|
|
|
|
|
old_owner = NULL;
|
|
|
|
|
base_service_from_bus = NULL;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
message = initial_message;
|
2003-04-10 01:15:28 +00:00
|
|
|
dbus_message_ref (message);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged"))
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData socd;
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
reget_service_name_arg:
|
2004-09-24 10:43:36 +00:00
|
|
|
base_service = NULL;
|
|
|
|
|
old_owner = NULL;
|
|
|
|
|
base_service_from_bus = NULL;
|
|
|
|
|
|
2003-04-07 23:28:16 +00:00
|
|
|
if (!dbus_message_get_args (message, &error,
|
2004-09-24 10:43:36 +00:00
|
|
|
DBUS_TYPE_STRING, &base_service,
|
2005-07-14 20:44:15 +00:00
|
|
|
DBUS_TYPE_STRING, &old_owner,
|
2004-09-24 10:43:36 +00:00
|
|
|
DBUS_TYPE_STRING, &base_service_from_bus,
|
2003-04-07 23:28:16 +00:00
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged (creation)",
|
2003-04-10 05:12:19 +00:00
|
|
|
error.message);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
if (*base_service != ':')
|
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",
|
2004-09-24 10:43:36 +00:00
|
|
|
base_service);
|
2003-04-10 01:15:28 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
|
|
|
|
|
if (strcmp (base_service, base_service_from_bus) != 0)
|
2005-07-14 20:44:15 +00:00
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
_dbus_warn ("Expected base service activation, got \"%s\" instead with owner \"%s\"\n",
|
|
|
|
|
base_service, base_service_from_bus);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (old_owner[0])
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Received an old_owner argument during base service activation, \"%s\"\n",
|
|
|
|
|
old_owner);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
socd.expected_kind = SERVICE_CREATED;
|
|
|
|
|
socd.expected_service_name = base_service;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = connection;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
2003-04-10 01:15:28 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
if (socd.failed)
|
2003-04-10 01:15:28 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-10 05:12:19 +00:00
|
|
|
else
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
warn_unexpected (connection, message, "NameOwnerChanged (creation) for base service");
|
2003-08-18 22:43:30 +00:00
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
if (base_service_p)
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
*base_service_p = base_service;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
2003-04-10 01:15:28 +00:00
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
2004-09-24 10:43:36 +00:00
|
|
|
dbus_error_free (&error);
|
2003-04-10 01:15:28 +00:00
|
|
|
|
|
|
|
|
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-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged"))
|
2003-04-10 01:15:28 +00:00
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData socd;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *service_name, *base_service_from_bus, *old_owner;
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
reget_service_name_arg:
|
2004-09-24 10:43:36 +00:00
|
|
|
service_name = NULL;
|
|
|
|
|
old_owner = NULL;
|
|
|
|
|
base_service_from_bus = NULL;
|
|
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
2005-07-14 20:44:15 +00:00
|
|
|
DBUS_TYPE_STRING, &old_owner,
|
2004-09-24 10:43:36 +00:00
|
|
|
DBUS_TYPE_STRING, &base_service_from_bus,
|
2003-04-10 01:15:28 +00:00
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged (creation)",
|
2003-04-10 05:12:19 +00:00
|
|
|
error.message);
|
|
|
|
|
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);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
if (strcmp (base_service_name, base_service_from_bus) != 0)
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_warn ("NameOwnerChanged reports wrong base service: %s owner, expected %s instead\n",
|
2004-09-24 10:43:36 +00:00
|
|
|
base_service_from_bus, base_service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (old_owner[0])
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("expected a %s, got a %s\n",
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged (creation)",
|
|
|
|
|
"NameOwnerChanged (change)");
|
2004-09-24 10:43:36 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
socd.expected_kind = SERVICE_CREATED;
|
|
|
|
|
socd.skip_connection = connection;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.expected_service_name = service_name;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
|
|
|
|
|
|
|
|
|
if (socd.failed)
|
2003-04-07 23:28:16 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
service_name = NULL;
|
|
|
|
|
old_owner = NULL;
|
|
|
|
|
base_service_from_bus = NULL;
|
|
|
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName");
|
2003-04-07 23:28:16 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-10 05:12:19 +00:00
|
|
|
else
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
warn_unexpected (connection, message, "NameOwnerChanged for the activated name");
|
2003-08-18 22:43:30 +00:00
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
2003-04-07 23:28:16 +00:00
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
warn_unexpected (connection, message, "reply to StartServiceByName");
|
2003-08-18 22:43:30 +00:00
|
|
|
|
2003-04-07 23:28:16 +00:00
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName", error.message);
|
2003-04-07 23:28:16 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
if (activation_result == DBUS_START_REPLY_SUCCESS)
|
2003-04-07 23:28:16 +00:00
|
|
|
; /* Good */
|
2005-01-18 20:42:15 +00:00
|
|
|
else if (activation_result == DBUS_START_REPLY_ALREADY_RUNNING)
|
2003-04-07 23:28:16 +00:00
|
|
|
; /* Good also */
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_warn ("Activation result was %u, no good.\n",
|
2003-04-07 23:28:16 +00:00
|
|
|
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);
|
2004-09-24 10:43:36 +00:00
|
|
|
dbus_error_free (&error);
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 18:00:35 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
check_service_auto_activated (BusContext *context,
|
2005-07-14 20:44:15 +00:00
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *activated_name,
|
|
|
|
|
const char *base_service_name,
|
|
|
|
|
DBusMessage *initial_message)
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
message = initial_message;
|
|
|
|
|
dbus_message_ref (message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged"))
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *service_name;
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData socd;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
reget_service_name_arg:
|
|
|
|
|
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_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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged",
|
2004-03-16 18:00:35 +00:00
|
|
|
error.message);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp (service_name, activated_name) != 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Expected to see service %s created, saw %s instead\n",
|
|
|
|
|
activated_name, service_name);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
socd.expected_kind = SERVICE_CREATED;
|
|
|
|
|
socd.expected_service_name = service_name;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = connection;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
2005-07-14 20:44:15 +00:00
|
|
|
&socd);
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
if (socd.failed)
|
2004-03-16 18:00:35 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Note that this differs from regular activation in that we don't get a
|
|
|
|
|
* reply to ActivateService here.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
service_name = NULL;
|
2004-03-16 18:00:35 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
warn_unexpected (connection, message, "NameOwnerChanged for the activated name");
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
check_service_deactivated (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *activated_name,
|
|
|
|
|
const char *base_service)
|
|
|
|
|
{
|
|
|
|
|
dbus_bool_t retval;
|
2004-09-24 10:43:36 +00:00
|
|
|
CheckServiceOwnerChangedData socd;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
/* Now we are expecting ServiceOwnerChanged (deletion) messages for the base
|
2003-04-07 23:28:16 +00:00
|
|
|
* 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
|
|
|
*/
|
2004-09-24 10:43:36 +00:00
|
|
|
socd.expected_kind = SERVICE_DELETED;
|
|
|
|
|
socd.expected_service_name = activated_name;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = NULL;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
|
|
|
|
|
|
|
|
|
if (socd.failed)
|
2003-04-07 23:28:16 +00:00
|
|
|
goto out;
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
socd.expected_kind = SERVICE_DELETED;
|
|
|
|
|
socd.expected_service_name = base_service;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = NULL;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
|
|
|
|
|
|
|
|
|
if (socd.failed)
|
2003-04-07 23:28:16 +00:00
|
|
|
goto out;
|
2003-04-09 20:31:21 +00:00
|
|
|
|
|
|
|
|
retval = TRUE;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
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;
|
2003-09-21 19:53:56 +00:00
|
|
|
dbus_uint32_t serial;
|
2003-04-10 05:12:19 +00:00
|
|
|
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-31 01:51:44 +00:00
|
|
|
message = dbus_message_new_method_call (service_name,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Exit");
|
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 */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
/* 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);
|
2004-07-31 09:15:24 +00:00
|
|
|
message = borrow_message_waiting_for_memory (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 */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "test service to exit");
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (got_error)
|
|
|
|
|
{
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
_dbus_assert (message != NULL);
|
|
|
|
|
|
2003-10-28 23:51:24 +00:00
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message,
|
|
|
|
|
"error with the correct reply serial");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-18 22:43:30 +00:00
|
|
|
if (!dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-04-10 05:12:19 +00:00
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message,
|
|
|
|
|
"a no memory error from asking test service to exit");
|
2003-04-10 05:12:19 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Got error %s when asking test service to exit\n",
|
2003-08-18 22:43:30 +00:00
|
|
|
dbus_message_get_error_name (message));
|
2003-04-10 05:12:19 +00:00
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
2003-10-28 23:51:24 +00:00
|
|
|
/* Should now have a NoReply error from the Exit() method
|
|
|
|
|
* call; it should have come after all the deactivation
|
|
|
|
|
* stuff.
|
|
|
|
|
*/
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, NULL,
|
|
|
|
|
"reply to Exit() method call");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
if (!dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_REPLY))
|
|
|
|
|
{
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
warn_unexpected (connection, message,
|
2003-10-28 23:51:24 +00:00
|
|
|
"NoReply error from Exit() method call");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message,
|
|
|
|
|
"error with the correct reply serial");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Got error %s after test service exited\n",
|
|
|
|
|
dbus_message_get_error_name (message));
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Messages were left over after %s\n",
|
|
|
|
|
_DBUS_FUNCTION_NAME);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
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
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message, "an error");
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
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-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_error (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-08-18 22:43:30 +00:00
|
|
|
dbus_message_get_error_name (message));
|
2003-04-11 00:03:06 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
GOT_SERVICE_CREATED,
|
|
|
|
|
GOT_SERVICE_DELETED,
|
|
|
|
|
GOT_ERROR,
|
|
|
|
|
GOT_SOMETHING_ELSE
|
|
|
|
|
} GotServiceInfo;
|
|
|
|
|
|
|
|
|
|
static GotServiceInfo
|
|
|
|
|
check_got_service_info (DBusMessage *message)
|
|
|
|
|
{
|
|
|
|
|
GotServiceInfo message_kind;
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_signal (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"NameOwnerChanged"))
|
2004-09-24 10:43:36 +00:00
|
|
|
{
|
|
|
|
|
DBusError error;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *service_name, *old_owner, *new_owner;
|
2004-09-24 10:43:36 +00:00
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
reget_service_info_data:
|
|
|
|
|
service_name = NULL;
|
|
|
|
|
old_owner = NULL;
|
|
|
|
|
new_owner = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_STRING, &service_name,
|
|
|
|
|
DBUS_TYPE_STRING, &old_owner,
|
|
|
|
|
DBUS_TYPE_STRING, &new_owner,
|
|
|
|
|
DBUS_TYPE_INVALID);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto reget_service_info_data;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("unexpected arguments for NameOwnerChanged message\n");
|
2004-09-24 10:43:36 +00:00
|
|
|
message_kind = GOT_SOMETHING_ELSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!old_owner[0])
|
|
|
|
|
message_kind = GOT_SERVICE_CREATED;
|
|
|
|
|
else if (!new_owner[0])
|
|
|
|
|
message_kind = GOT_SERVICE_DELETED;
|
|
|
|
|
else
|
|
|
|
|
message_kind = GOT_SOMETHING_ELSE;
|
|
|
|
|
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
message_kind = GOT_ERROR;
|
|
|
|
|
else
|
|
|
|
|
message_kind = GOT_SOMETHING_ELSE;
|
|
|
|
|
|
|
|
|
|
return message_kind;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
2005-01-21 03:44:10 +00:00
|
|
|
check_existent_service_no_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2003-04-04 00:39:22 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBusMessage *base_service_message;
|
|
|
|
|
const char *base_service;
|
2003-09-21 19:53:56 +00:00
|
|
|
dbus_uint32_t serial;
|
2003-04-04 00:39:22 +00:00
|
|
|
dbus_bool_t retval;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *existent = EXISTENT_SERVICE_NAME;
|
|
|
|
|
dbus_uint32_t flags;
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
base_service_message = NULL;
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName");
|
2003-04-04 00:39:22 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2005-01-21 03:44:10 +00:00
|
|
|
dbus_message_set_auto_start (message, FALSE);
|
|
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
flags = 0;
|
2003-04-04 00:39:22 +00:00
|
|
|
if (!dbus_message_append_args (message,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &existent,
|
|
|
|
|
DBUS_TYPE_UINT32, &flags,
|
2003-04-04 00:39:22 +00:00
|
|
|
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.
|
|
|
|
|
*/
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "activated service to connect");
|
2003-04-10 05:12:19 +00:00
|
|
|
|
2003-04-04 00:39:22 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2003-04-04 00:39:22 +00:00
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName", serial, connection);
|
2003-04-04 00:39:22 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-20 14:48:04 +00:00
|
|
|
verbose_message_received (connection, message);
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_verbose (" (after sending %s)\n", "StartServiceByName");
|
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
|
|
|
{
|
2005-02-17 21:19:49 +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-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_error (message,
|
2003-04-24 21:26:25 +00:00
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-04-04 00:39:22 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2003-08-18 22:43:30 +00:00
|
|
|
else if (dbus_message_is_error (message,
|
2004-09-17 09:14:49 +00:00
|
|
|
DBUS_ERROR_SPAWN_CHILD_EXITED) ||
|
2005-09-11 10:02:47 +00:00
|
|
|
dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_SIGNALED) ||
|
2004-09-17 09:14:49 +00:00
|
|
|
dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_EXEC_FAILED))
|
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",
|
2003-08-18 22:43:30 +00:00
|
|
|
dbus_message_get_error_name (message));
|
2003-04-04 00:39:22 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
GotServiceInfo message_kind;
|
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;
|
|
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
base_service_message = message;
|
2003-04-07 23:28:16 +00:00
|
|
|
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 */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "test service to exit or finish up");
|
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
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
message_kind = check_got_service_info (message);
|
|
|
|
|
|
2003-04-10 01:15:28 +00:00
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
2003-04-11 00:03:06 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
switch (message_kind)
|
2005-07-14 20:44:15 +00:00
|
|
|
{
|
|
|
|
|
case GOT_SOMETHING_ELSE:
|
2004-09-24 10:43:36 +00:00
|
|
|
_dbus_warn ("Unexpected message after ActivateService "
|
|
|
|
|
"(should be an error or a service announcement");
|
2005-07-14 20:44:15 +00:00
|
|
|
goto out;
|
2004-09-24 10:43:36 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
case GOT_ERROR:
|
2003-04-11 00:03:06 +00:00
|
|
|
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.
|
|
|
|
|
*/
|
2003-04-07 23:28:16 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
|
|
case GOT_SERVICE_DELETED:
|
|
|
|
|
{
|
|
|
|
|
/* The service started up and got a base address, but then
|
|
|
|
|
* failed to register under EXISTENT_SERVICE_NAME
|
|
|
|
|
*/
|
|
|
|
|
CheckServiceOwnerChangedData socd;
|
|
|
|
|
|
|
|
|
|
socd.expected_kind = SERVICE_DELETED;
|
|
|
|
|
socd.expected_service_name = base_service;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = NULL;
|
|
|
|
|
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
|
|
|
|
|
|
|
|
|
if (socd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Now we should get an error about the service exiting
|
|
|
|
|
* if we didn't get it before.
|
|
|
|
|
*/
|
|
|
|
|
if (message_kind != GOT_ERROR)
|
|
|
|
|
{
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "error about service exiting");
|
2006-10-23 17:25:52 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
/* and process everything again */
|
|
|
|
|
bus_test_run_everything (context);
|
2003-04-11 00:03:06 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
if (!check_got_error (context, connection,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_EXITED,
|
2006-10-23 17:25:52 +00:00
|
|
|
DBUS_ERROR_NO_MEMORY,
|
2005-07-14 20:44:15 +00:00
|
|
|
NULL))
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GOT_SERVICE_CREATED:
|
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)
|
|
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
_dbus_warn ("Failed to pop message we just put back! "
|
2005-07-14 20:44:15 +00:00
|
|
|
"should have been a NameOwnerChanged (creation)\n");
|
2003-04-10 01:15:28 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-14 01:17:59 +00:00
|
|
|
if (!check_send_exit_to_service (context, connection,
|
2003-04-10 05:12:19 +00:00
|
|
|
EXISTENT_SERVICE_NAME, base_service))
|
2006-07-14 01:17:59 +00:00
|
|
|
goto out;
|
2004-09-24 10:43:36 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2003-04-04 00:39:22 +00:00
|
|
|
}
|
2004-09-24 10:43:36 +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
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
if (base_service_message)
|
|
|
|
|
dbus_message_unref (base_service_message);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-08 08:30:17 +00:00
|
|
|
#ifndef DBUS_WIN_FIXME
|
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
|
2005-01-21 03:44:10 +00:00
|
|
|
check_segfault_service_no_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2003-04-11 03:45:40 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
2003-09-21 19:53:56 +00:00
|
|
|
dbus_uint32_t serial;
|
2003-04-11 03:45:40 +00:00
|
|
|
dbus_bool_t retval;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *segv_service;
|
|
|
|
|
dbus_uint32_t flags;
|
2003-04-11 03:45:40 +00:00
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName");
|
2003-04-11 03:45:40 +00:00
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2005-01-21 03:44:10 +00:00
|
|
|
dbus_message_set_auto_start (message, FALSE);
|
|
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
segv_service = "org.freedesktop.DBus.TestSuiteSegfaultService";
|
|
|
|
|
flags = 0;
|
2003-04-11 03:45:40 +00:00
|
|
|
if (!dbus_message_append_args (message,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &segv_service,
|
|
|
|
|
DBUS_TYPE_UINT32, &flags,
|
2003-04-11 03:45:40 +00:00
|
|
|
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);
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to activating segfault service");
|
2003-04-11 03:45:40 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2003-04-11 03:45:40 +00:00
|
|
|
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",
|
2005-01-18 20:42:15 +00:00
|
|
|
"StartServiceByName", serial, connection);
|
2003-04-11 03:45:40 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-20 14:48:04 +00:00
|
|
|
verbose_message_received (connection, message);
|
2003-04-11 03:45:40 +00:00
|
|
|
|
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
|
|
|
{
|
2005-02-17 21:19:49 +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-08-18 22:43:30 +00:00
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
2003-04-11 03:45:40 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
2007-07-24 12:39:30 +00:00
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_FAILED))
|
|
|
|
|
{
|
|
|
|
|
const char *servicehelper;
|
|
|
|
|
servicehelper = bus_context_get_servicehelper (context);
|
|
|
|
|
/* make sure this only happens with the launch helper */
|
|
|
|
|
_dbus_assert (servicehelper != NULL);
|
|
|
|
|
}
|
2003-08-18 22:43:30 +00:00
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_SIGNALED))
|
2003-04-11 03:45:40 +00:00
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-08-18 22:43:30 +00:00
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
2003-04-11 03:45:40 +00:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
2005-01-21 03:44:10 +00:00
|
|
|
check_segfault_service_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteSegfaultService",
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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);
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to Echo on segfault service");
|
2004-03-16 18:00:35 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2004-03-16 18:00:35 +00:00
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_SIGNALED))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2007-03-08 08:30:17 +00:00
|
|
|
#endif
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
#define TEST_ECHO_MESSAGE "Test echo message"
|
2005-07-15 15:21:43 +00:00
|
|
|
#define TEST_RUN_HELLO_FROM_SELF_MESSAGE "Test sending message to self"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_existent_hello_from_self (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
const char *text;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (EXISTENT_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"RunHelloFromSelf");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
text = TEST_RUN_HELLO_FROM_SELF_MESSAGE;
|
|
|
|
|
if (!dbus_message_append_args (message,
|
|
|
|
|
DBUS_TYPE_STRING, &text,
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* Note: if this test is run in OOM mode, it will block when the bus
|
|
|
|
|
* doesn't send a reply due to OOM.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply from running hello from self");
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message! Should have been reply from RunHelloFromSelf message\n");
|
2005-09-11 10:02:47 +00:00
|
|
|
return FALSE;
|
2005-07-15 15:21:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Wrong reply serial\n");
|
2005-09-11 10:02:47 +00:00
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
2005-07-15 15:21:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
2005-09-11 10:02:47 +00:00
|
|
|
return TRUE;
|
2005-07-15 15:21:43 +00:00
|
|
|
}
|
|
|
|
|
|
2005-10-03 19:55:56 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_existent_ping (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
message = dbus_message_new_method_call (EXISTENT_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.DBus.Peer",
|
|
|
|
|
"Ping");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* Note: if this test is run in OOM mode, it will block when the bus
|
|
|
|
|
* doesn't send a reply due to OOM.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply from running Ping");
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message! Should have been reply from Ping message\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Wrong reply serial\n");
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Unexpected message return during Ping\n");
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2006-09-30 Havoc Pennington <hp@redhat.com>
* configure.in (LT_CURRENT, LT_AGE): increment current and age to
reflect addition of interfaces.
* doc/dbus-specification.xml: describe a new
org.freedesktop.DBus.Peer.GetMachineId method
* dbus/dbus-string.c (_dbus_string_skip_white_reverse): new function
(_dbus_string_skip_white, _dbus_string_skip_blank): use new
DBUS_IS_ASCII_BLANK, DBUS_IS_ASCII_WHITE macros and fix assertion
at end of skip_white
(_dbus_string_chop_white): new function
* bus/connection.c (bus_connections_setup_connection): call
dbus_connection_set_route_peer_messages.
* dbus/dbus-connection.c
(_dbus_connection_peer_filter_unlocked_no_update): modify to
support a GetMachineId method.
Also, support a new flag to let the bus pass peer methods through
to apps on the bus, which can be set with
dbus_connection_set_route_peer_messages.
Finally, handle and return an error for anything unknown on the
Peer interface, which will allow us to extend the Peer interface
in the future without fear that we're now intercepting something
apps were wanting to see.
* tools/dbus-uuidgen.c: a thin wrapper around the functions in
dbus/dbus-uuidgen.c
* dbus/dbus-uuidgen.c: implement the bulk of the dbus-uuidgen
binary here, since most of the code is already in libdbus
* dbus/dbus-sysdeps.c (_dbus_read_local_machine_uuid): read the
uuid from the system config file
* dbus/dbus-internals.c (_dbus_generate_uuid, _dbus_uuid_encode)
(_dbus_read_uuid_file_without_creating)
(_dbus_create_uuid_file_exclusively, _dbus_read_uuid_file): new
uuid-related functions, partly factored out from dbus-server.c
* dbus/dbus-sysdeps.c (_dbus_error_from_errno): convert EEXIST to
DBUS_ERROR_FILE_EXISTS instead of EEXIST
* dbus/dbus-protocol.h (DBUS_ERROR_FILE_EXISTS): add file exists error
* tools/dbus-cleanup-sockets.1: explain what the point of this
thing is a bit more
* autogen.sh (run_configure): add --config-cache to default
configure args
* dbus/dbus-internals.h (_DBUS_ASSERT_ERROR_IS_SET): disable the
error set/clear assertions when DBUS_DISABLE_CHECKS is defined
* tools/dbus-launch.c (main): if xdisplay hasn't been opened,
don't try to save address, fixes crash in make check
2006-10-01 03:18:47 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_existent_get_machine_id (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
const char *machine_id;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (EXISTENT_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.DBus.Peer",
|
|
|
|
|
"GetMachineId");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* Note: if this test is run in OOM mode, it will block when the bus
|
|
|
|
|
* doesn't send a reply due to OOM.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply from running GetMachineId");
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message! Should have been reply from GetMachineId message\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Wrong reply serial\n");
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Unexpected message return during GetMachineId\n");
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
machine_id = NULL;
|
|
|
|
|
if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &machine_id, DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not get a machine ID in reply to GetMachineId\n");
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (machine_id == NULL || strlen (machine_id) != 32)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Machine id looks bogus: '%s'\n", machine_id ? machine_id : "null");
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We can't check that the machine id is correct because during make check it is
|
|
|
|
|
* just made up for each process separately
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 18:00:35 +00:00
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
2005-01-21 03:44:10 +00:00
|
|
|
check_existent_service_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBusMessage *base_service_message;
|
2004-03-16 18:00:35 +00:00
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
const char *base_service;
|
|
|
|
|
const char *text;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
base_service_message = NULL;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (EXISTENT_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
text = TEST_ECHO_MESSAGE;
|
2004-03-16 18:00:35 +00:00
|
|
|
if (!dbus_message_append_args (message,
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
DBUS_TYPE_STRING, &text,
|
2004-03-16 18:00:35 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* now wait for the message bus to hear back from the activated
|
|
|
|
|
* service.
|
|
|
|
|
*/
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to Echo on existent service");
|
2004-03-16 18:00:35 +00:00
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
2004-03-16 18:00:35 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_warn ("Did not receive any messages after auto start %d on %p\n",
|
2004-03-16 18:00:35 +00:00
|
|
|
serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
2005-01-18 20:42:15 +00:00
|
|
|
_dbus_verbose (" (after sending %s)\n", "auto start");
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
/* we should get zero or two ServiceOwnerChanged signals */
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_SIGNAL)
|
2004-03-16 18:00:35 +00:00
|
|
|
{
|
2004-09-24 10:43:36 +00:00
|
|
|
GotServiceInfo message_kind;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
if (!check_base_service_activated (context, connection,
|
|
|
|
|
message, &base_service))
|
2005-07-14 20:44:15 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
base_service_message = message;
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
/* We may need to block here for the test service to exit or finish up */
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "service to exit");
|
|
|
|
|
|
|
|
|
|
/* Should get a service creation notification for the activated
|
|
|
|
|
* service name, or a service deletion on the base service name
|
|
|
|
|
*/
|
|
|
|
|
message = dbus_connection_borrow_message (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("No message after auto activation "
|
2006-10-23 17:25:52 +00:00
|
|
|
"(should be a service announcement)\n");
|
2005-07-14 20:44:15 +00:00
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message_kind = check_got_service_info (message);
|
|
|
|
|
|
|
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
switch (message_kind)
|
|
|
|
|
{
|
|
|
|
|
case GOT_SERVICE_CREATED:
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message we just put back! "
|
|
|
|
|
"should have been a NameOwnerChanged (creation)\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check that ServiceOwnerChanged (creation) was correctly received */
|
|
|
|
|
if (!check_service_auto_activated (context, connection, EXISTENT_SERVICE_NAME,
|
|
|
|
|
base_service, message))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GOT_SERVICE_DELETED:
|
|
|
|
|
{
|
|
|
|
|
/* The service started up and got a base address, but then
|
|
|
|
|
* failed to register under EXISTENT_SERVICE_NAME
|
|
|
|
|
*/
|
|
|
|
|
CheckServiceOwnerChangedData socd;
|
|
|
|
|
|
|
|
|
|
socd.expected_kind = SERVICE_DELETED;
|
|
|
|
|
socd.expected_service_name = base_service;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = NULL;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
|
|
|
|
|
|
|
|
|
if (socd.failed)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case GOT_ERROR:
|
|
|
|
|
case GOT_SOMETHING_ELSE:
|
|
|
|
|
_dbus_warn ("Unexpected message after auto activation\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* OK, now we've dealt with ServiceOwnerChanged signals, now should
|
|
|
|
|
* come the method reply (or error) from the initial method call
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Note: if this test is run in OOM mode, it will block when the bus
|
|
|
|
|
* doesn't send a reply due to OOM.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply from echo message after auto-activation");
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message! Should have been reply from echo message\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Wrong reply serial\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
2005-07-15 15:21:43 +00:00
|
|
|
|
2005-10-03 19:55:56 +00:00
|
|
|
if (!check_existent_ping (context, connection))
|
|
|
|
|
goto out;
|
|
|
|
|
|
2006-09-30 Havoc Pennington <hp@redhat.com>
* configure.in (LT_CURRENT, LT_AGE): increment current and age to
reflect addition of interfaces.
* doc/dbus-specification.xml: describe a new
org.freedesktop.DBus.Peer.GetMachineId method
* dbus/dbus-string.c (_dbus_string_skip_white_reverse): new function
(_dbus_string_skip_white, _dbus_string_skip_blank): use new
DBUS_IS_ASCII_BLANK, DBUS_IS_ASCII_WHITE macros and fix assertion
at end of skip_white
(_dbus_string_chop_white): new function
* bus/connection.c (bus_connections_setup_connection): call
dbus_connection_set_route_peer_messages.
* dbus/dbus-connection.c
(_dbus_connection_peer_filter_unlocked_no_update): modify to
support a GetMachineId method.
Also, support a new flag to let the bus pass peer methods through
to apps on the bus, which can be set with
dbus_connection_set_route_peer_messages.
Finally, handle and return an error for anything unknown on the
Peer interface, which will allow us to extend the Peer interface
in the future without fear that we're now intercepting something
apps were wanting to see.
* tools/dbus-uuidgen.c: a thin wrapper around the functions in
dbus/dbus-uuidgen.c
* dbus/dbus-uuidgen.c: implement the bulk of the dbus-uuidgen
binary here, since most of the code is already in libdbus
* dbus/dbus-sysdeps.c (_dbus_read_local_machine_uuid): read the
uuid from the system config file
* dbus/dbus-internals.c (_dbus_generate_uuid, _dbus_uuid_encode)
(_dbus_read_uuid_file_without_creating)
(_dbus_create_uuid_file_exclusively, _dbus_read_uuid_file): new
uuid-related functions, partly factored out from dbus-server.c
* dbus/dbus-sysdeps.c (_dbus_error_from_errno): convert EEXIST to
DBUS_ERROR_FILE_EXISTS instead of EEXIST
* dbus/dbus-protocol.h (DBUS_ERROR_FILE_EXISTS): add file exists error
* tools/dbus-cleanup-sockets.1: explain what the point of this
thing is a bit more
* autogen.sh (run_configure): add --config-cache to default
configure args
* dbus/dbus-internals.h (_DBUS_ASSERT_ERROR_IS_SET): disable the
error set/clear assertions when DBUS_DISABLE_CHECKS is defined
* tools/dbus-launch.c (main): if xdisplay hasn't been opened,
don't try to save address, fixes crash in make check
2006-10-01 03:18:47 +00:00
|
|
|
if (!check_existent_get_machine_id (context, connection))
|
|
|
|
|
goto out;
|
|
|
|
|
|
2005-07-15 15:21:43 +00:00
|
|
|
if (!check_existent_hello_from_self (context, connection))
|
|
|
|
|
goto out;
|
|
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
if (!check_send_exit_to_service (context, connection,
|
|
|
|
|
EXISTENT_SERVICE_NAME,
|
|
|
|
|
base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
if (base_service_message)
|
|
|
|
|
dbus_message_unref (base_service_message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
#define SERVICE_FILE_MISSING_NAME "org.freedesktop.DBus.TestSuiteEchoServiceDotServiceFileDoesNotExist"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_launch_service_file_missing (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (SERVICE_FILE_MISSING_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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, "reply to service file missing should fail to auto-start");
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SERVICE_UNKNOWN))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("got service unknown\n");
|
|
|
|
|
; /* good, this is expected (only valid when using launch helper) */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully auto-start missing service\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SERVICE_USER_MISSING_NAME "org.freedesktop.DBus.TestSuiteNoUser"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_launch_service_user_missing (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (SERVICE_USER_MISSING_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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,
|
|
|
|
|
"reply to service which should fail to auto-start (missing User)");
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_FILE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("got service file invalid\n");
|
|
|
|
|
; /* good, this is expected (only valid when using launch helper) */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully auto-start missing service\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SERVICE_EXEC_MISSING_NAME "org.freedesktop.DBus.TestSuiteNoExec"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_launch_service_exec_missing (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (SERVICE_EXEC_MISSING_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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,
|
|
|
|
|
"reply to service which should fail to auto-start (missing Exec)");
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SERVICE_UNKNOWN))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("could not activate as invalid service file was not added\n");
|
|
|
|
|
; /* good, this is expected as we shouldn't have been added to
|
|
|
|
|
* the activation list with a missing Exec key */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_FILE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("got service file invalid\n");
|
|
|
|
|
; /* good, this is allowed, and is the message passed back from the
|
|
|
|
|
* launch helper */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully auto-start missing service\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SERVICE_SERVICE_MISSING_NAME "org.freedesktop.DBus.TestSuiteNoService"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_launch_service_service_missing (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (SERVICE_SERVICE_MISSING_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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,
|
|
|
|
|
"reply to service which should fail to auto-start (missing Service)");
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SERVICE_UNKNOWN))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("could not activate as invalid service file was not added\n");
|
|
|
|
|
; /* good, this is expected as we shouldn't have been added to
|
|
|
|
|
* the activation list with a missing Exec key */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_FILE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("got service file invalid\n");
|
|
|
|
|
; /* good, this is allowed, and is the message passed back from the
|
|
|
|
|
* launch helper */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully auto-start missing service\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
#define SHELL_FAIL_SERVICE_NAME "org.freedesktop.DBus.TestSuiteShellEchoServiceFail"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_shell_fail_service_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (SHELL_FAIL_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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, "reply to shell Echo on service which should fail to auto-start");
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
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",
|
|
|
|
|
"Echo message (auto activation)", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_INVALID_ARGS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose("got invalid args\n");
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect to successfully auto-start shell fail service\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SHELL_SUCCESS_SERVICE_NAME "org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess"
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_shell_service_success_auto_start (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusMessage *base_service_message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
const char *base_service;
|
|
|
|
|
const char *argv[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
|
|
|
|
|
|
|
|
|
base_service_message = NULL;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (SHELL_SUCCESS_SERVICE_NAME,
|
|
|
|
|
"/org/freedesktop/TestSuite",
|
|
|
|
|
"org.freedesktop.TestSuite",
|
|
|
|
|
"Echo");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* now wait for the message bus to hear back from the activated
|
|
|
|
|
* service.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to Echo on shell success service");
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive any messages after auto start %d on %p\n",
|
|
|
|
|
serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
_dbus_verbose (" (after sending %s)\n", "auto start");
|
|
|
|
|
|
|
|
|
|
/* we should get zero or two ServiceOwnerChanged signals */
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_SIGNAL)
|
|
|
|
|
{
|
|
|
|
|
GotServiceInfo message_kind;
|
|
|
|
|
|
|
|
|
|
if (!check_base_service_activated (context, connection,
|
|
|
|
|
message, &base_service))
|
|
|
|
|
goto out;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
base_service_message = message;
|
2004-03-16 18:00:35 +00:00
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
/* We may need to block here for the test service to exit or finish up */
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "service to exit");
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
/* Should get a service creation notification for the activated
|
|
|
|
|
* service name, or a service deletion on the base service name
|
2004-03-16 18:00:35 +00:00
|
|
|
*/
|
|
|
|
|
message = dbus_connection_borrow_message (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
2005-07-14 20:44:15 +00:00
|
|
|
_dbus_warn ("No message after auto activation "
|
2006-10-23 17:25:52 +00:00
|
|
|
"(should be a service announcement)\n");
|
2005-07-14 20:44:15 +00:00
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
2004-03-16 18:00:35 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
message_kind = check_got_service_info (message);
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
switch (message_kind)
|
2005-07-14 20:44:15 +00:00
|
|
|
{
|
|
|
|
|
case GOT_SERVICE_CREATED:
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message we just put back! "
|
|
|
|
|
"should have been a NameOwnerChanged (creation)\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check that ServiceOwnerChanged (creation) was correctly received */
|
|
|
|
|
if (!check_service_auto_activated (context, connection, SHELL_SUCCESS_SERVICE_NAME,
|
|
|
|
|
base_service, message))
|
|
|
|
|
goto out;
|
2004-09-24 10:43:36 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
break;
|
2004-09-24 10:43:36 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
case GOT_SERVICE_DELETED:
|
|
|
|
|
{
|
|
|
|
|
/* The service started up and got a base address, but then
|
|
|
|
|
* failed to register under SHELL_SUCCESS_SERVICE_NAME
|
|
|
|
|
*/
|
|
|
|
|
CheckServiceOwnerChangedData socd;
|
|
|
|
|
|
|
|
|
|
socd.expected_kind = SERVICE_DELETED;
|
|
|
|
|
socd.expected_service_name = base_service;
|
|
|
|
|
socd.failed = FALSE;
|
|
|
|
|
socd.skip_connection = NULL;
|
|
|
|
|
bus_test_clients_foreach (check_service_owner_changed_foreach,
|
|
|
|
|
&socd);
|
|
|
|
|
|
|
|
|
|
if (socd.failed)
|
|
|
|
|
goto out;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
|
|
|
|
|
case GOT_ERROR:
|
2005-07-14 20:44:15 +00:00
|
|
|
case GOT_SOMETHING_ELSE:
|
|
|
|
|
_dbus_warn ("Unexpected message after auto activation\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
}
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
/* OK, now we've dealt with ServiceOwnerChanged signals, now should
|
|
|
|
|
* come the method reply (or error) from the initial method call
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Note: if this test is run in OOM mode, it will block when the bus
|
|
|
|
|
* doesn't send a reply due to OOM.
|
|
|
|
|
*/
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
block_connection_until_message_from_bus (context, connection, "reply from echo message after auto-activation");
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message! Should have been reply from echo message\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_reply_serial (message) != serial)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Wrong reply serial\n");
|
|
|
|
|
goto out;
|
2004-03-16 18:00:35 +00:00
|
|
|
}
|
2004-09-24 10:43:36 +00:00
|
|
|
|
2005-07-14 20:44:15 +00:00
|
|
|
if (!dbus_message_get_args (message, NULL,
|
|
|
|
|
DBUS_TYPE_STRING, &argv[0],
|
|
|
|
|
DBUS_TYPE_STRING, &argv[1],
|
|
|
|
|
DBUS_TYPE_STRING, &argv[2],
|
|
|
|
|
DBUS_TYPE_STRING, &argv[3],
|
|
|
|
|
DBUS_TYPE_STRING, &argv[4],
|
|
|
|
|
DBUS_TYPE_STRING, &argv[5],
|
|
|
|
|
DBUS_TYPE_STRING, &argv[6],
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Error getting arguments from return\n");
|
2005-07-14 20:44:15 +00:00
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* don't worry about arg[0] as it may be different
|
|
|
|
|
depending on the path to the tests
|
|
|
|
|
*/
|
|
|
|
|
if (strcmp("-test", argv[1]) != 0)
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Unexpected argv[1] in shell success service test (expected: %s, got: %s)\n",
|
2005-07-14 20:44:15 +00:00
|
|
|
"-test", argv[1]);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp("that", argv[2]) != 0)
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Unexpected argv[2] in shell success service test (expected: %s, got: %s)\n",
|
2005-07-14 20:44:15 +00:00
|
|
|
"that", argv[2]);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp("we get", argv[3]) != 0)
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Unexpected argv[3] in shell success service test (expected: %s, got: %s)\n",
|
2005-07-14 20:44:15 +00:00
|
|
|
"we get", argv[3]);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp("back", argv[4]) != 0)
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Unexpected argv[4] in shell success service test (expected: %s, got: %s)\n",
|
2005-07-14 20:44:15 +00:00
|
|
|
"back", argv[4]);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp("--what", argv[5]) != 0)
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Unexpected argv[5] in shell success service test (expected: %s, got: %s)\n",
|
2005-07-14 20:44:15 +00:00
|
|
|
"--what", argv[5]);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp("we put in", argv[6]) != 0)
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Unexpected argv[6] in shell success service test (expected: %s, got: %s)\n",
|
2005-07-14 20:44:15 +00:00
|
|
|
"we put in", argv[6]);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-24 10:43:36 +00:00
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
if (!check_send_exit_to_service (context, connection,
|
2005-07-14 20:44:15 +00:00
|
|
|
SHELL_SUCCESS_SERVICE_NAME,
|
|
|
|
|
base_service))
|
2004-09-24 10:43:36 +00:00
|
|
|
goto out;
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-15 07:15:38 +00:00
|
|
|
if (base_service_message)
|
|
|
|
|
dbus_message_unref (base_service_message);
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2006-07-14 01:17:59 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
check_get_services (BusContext *context,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const char *method,
|
|
|
|
|
char ***services,
|
|
|
|
|
int *len)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
DBusError error;
|
|
|
|
|
char **srvs;
|
|
|
|
|
int l;
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
|
|
|
|
method);
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_send (connection, message, &serial))
|
|
|
|
|
{
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* send our message */
|
|
|
|
|
bus_test_run_clients_loop (SEND_PENDING (connection));
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
dbus_connection_ref (connection); /* because we may get disconnected */
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "reply to ListActivatableNames/ListNames");
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive a reply to %s %d on %p\n",
|
|
|
|
|
method, serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_is_error (message, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message, "not this error");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN)
|
|
|
|
|
{
|
|
|
|
|
; /* good, expected */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
warn_unexpected (connection, message,
|
|
|
|
|
"method_return for ListActivatableNames/ListNames");
|
|
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retry_get_property:
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_get_args (message, &error,
|
|
|
|
|
DBUS_TYPE_ARRAY,
|
|
|
|
|
DBUS_TYPE_STRING,
|
|
|
|
|
&srvs, &l,
|
|
|
|
|
DBUS_TYPE_INVALID))
|
|
|
|
|
{
|
|
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("no memory to list services by %s\n", method);
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
goto retry_get_property;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (dbus_error_is_set (&error));
|
|
|
|
|
_dbus_warn ("Did not get the expected DBUS_TYPE_ARRAY from %s\n", method);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
*services = srvs;
|
|
|
|
|
*len = l;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* returns TRUE if the correct thing happens,
|
|
|
|
|
* but the correct thing may include OOM errors.
|
|
|
|
|
*/
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
check_list_services (BusContext *context,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusMessage *base_service_message;
|
|
|
|
|
const char *base_service;
|
|
|
|
|
dbus_uint32_t serial;
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
const char *existent = EXISTENT_SERVICE_NAME;
|
|
|
|
|
dbus_uint32_t flags;
|
|
|
|
|
char **services;
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("check_list_services for %p\n", connection);
|
|
|
|
|
|
|
|
|
|
if (!check_get_services (context, connection, "ListActivatableNames", &services, &len))
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_array_contains ((const char **)services, existent))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not get the expected %s from ListActivatableNames\n", existent);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
|
|
|
|
|
base_service_message = NULL;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new_method_call (DBUS_SERVICE_DBUS,
|
|
|
|
|
DBUS_PATH_DBUS,
|
|
|
|
|
DBUS_INTERFACE_DBUS,
|
|
|
|
|
"StartServiceByName");
|
|
|
|
|
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
dbus_message_set_auto_start (message, FALSE);
|
|
|
|
|
|
|
|
|
|
flags = 0;
|
|
|
|
|
if (!dbus_message_append_args (message,
|
|
|
|
|
DBUS_TYPE_STRING, &existent,
|
|
|
|
|
DBUS_TYPE_UINT32, &flags,
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
/* now wait for the message bus to hear back from the activated
|
|
|
|
|
* service.
|
|
|
|
|
*/
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "activated service to connect");
|
|
|
|
|
|
|
|
|
|
bus_test_run_everything (context);
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("connection was disconnected: %s %d\n", _DBUS_FUNCTION_NAME, __LINE__);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive any messages after %s %d on %p\n",
|
|
|
|
|
"StartServiceByName", serial, connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
verbose_message_received (connection, message);
|
|
|
|
|
_dbus_verbose (" (after sending %s)\n", "StartServiceByName");
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Message has wrong sender %s\n",
|
|
|
|
|
dbus_message_get_sender (message) ?
|
|
|
|
|
dbus_message_get_sender (message) : "(none)");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is a valid response */
|
|
|
|
|
}
|
|
|
|
|
else if (dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_EXITED) ||
|
|
|
|
|
dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_CHILD_SIGNALED) ||
|
|
|
|
|
dbus_message_is_error (message,
|
|
|
|
|
DBUS_ERROR_SPAWN_EXEC_FAILED))
|
|
|
|
|
{
|
|
|
|
|
; /* good, this is expected also */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not expect error %s\n",
|
|
|
|
|
dbus_message_get_error_name (message));
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GotServiceInfo message_kind;
|
|
|
|
|
|
|
|
|
|
if (!check_base_service_activated (context, connection,
|
|
|
|
|
message, &base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
base_service_message = message;
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
/* We may need to block here for the test service to exit or finish up */
|
|
|
|
|
block_connection_until_message_from_bus (context, connection, "test service to exit or finish up");
|
|
|
|
|
|
|
|
|
|
message = dbus_connection_borrow_message (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not receive any messages after base service creation notification\n");
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message_kind = check_got_service_info (message);
|
|
|
|
|
|
|
|
|
|
dbus_connection_return_message (connection, message);
|
|
|
|
|
message = NULL;
|
|
|
|
|
|
|
|
|
|
switch (message_kind)
|
|
|
|
|
{
|
|
|
|
|
case GOT_SOMETHING_ELSE:
|
|
|
|
|
case GOT_ERROR:
|
|
|
|
|
case GOT_SERVICE_DELETED:
|
|
|
|
|
_dbus_warn ("Unexpected message after ActivateService "
|
2006-10-23 17:25:52 +00:00
|
|
|
"(should be an error or a service announcement)\n");
|
2006-07-14 01:17:59 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
case GOT_SERVICE_CREATED:
|
|
|
|
|
message = pop_message_waiting_for_memory (connection);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Failed to pop message we just put back! "
|
|
|
|
|
"should have been a NameOwnerChanged (creation)\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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_get_services (context, connection, "ListNames", &services, &len))
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_array_contains ((const char **)services, existent))
|
|
|
|
|
{
|
|
|
|
|
_dbus_warn ("Did not get the expected %s from ListNames\n", existent);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_free_string_array (services);
|
|
|
|
|
|
|
|
|
|
if (!check_send_exit_to_service (context, connection,
|
|
|
|
|
EXISTENT_SERVICE_NAME, base_service))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (message)
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
|
|
|
|
|
if (base_service_message)
|
|
|
|
|
dbus_message_unref (base_service_message);
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Messages were left over, should be covered by test suite\n");
|
2003-04-02 20:14:52 +00:00
|
|
|
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))
|
2004-07-31 09:15:24 +00:00
|
|
|
{
|
|
|
|
|
_dbus_warn ("%s failed during oom\n", description);
|
|
|
|
|
_dbus_assert_not_reached ("test failed");
|
|
|
|
|
}
|
2003-04-02 20:14:52 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-24 22:11:00 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
setenv_TEST_LAUNCH_HELPER_CONFIG(const DBusString *test_data_dir,
|
|
|
|
|
const char *filename)
|
|
|
|
|
{
|
|
|
|
|
DBusString full;
|
|
|
|
|
DBusString file;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_init (&full))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_copy (test_data_dir, 0, &full, 0))
|
|
|
|
|
{
|
|
|
|
|
_dbus_string_free (&full);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_string_init_const (&file, filename);
|
|
|
|
|
|
|
|
|
|
if (!_dbus_concat_dir_and_file (&full, &file))
|
|
|
|
|
{
|
|
|
|
|
_dbus_string_free (&full);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Setting TEST_LAUNCH_HELPER_CONFIG to '%s'\n",
|
|
|
|
|
_dbus_string_get_const_data (&full));
|
|
|
|
|
|
|
|
|
|
_dbus_setenv ("TEST_LAUNCH_HELPER_CONFIG", _dbus_string_get_const_data (&full));
|
|
|
|
|
|
|
|
|
|
_dbus_string_free (&full);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_dispatch_test_conf (const DBusString *test_data_dir,
|
|
|
|
|
const char *filename,
|
|
|
|
|
dbus_bool_t use_launcher)
|
2003-03-14 01:27:58 +00:00
|
|
|
{
|
|
|
|
|
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
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
/* save the config name for the activation helper */
|
2007-07-24 22:11:00 +00:00
|
|
|
if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename))
|
|
|
|
|
_dbus_assert_not_reached ("no memory setting TEST_LAUNCH_HELPER_CONFIG");
|
2007-07-24 12:39:30 +00:00
|
|
|
|
2003-04-14 23:52:40 +00:00
|
|
|
dbus_error_init (&error);
|
2003-03-31 08:19:50 +00:00
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
context = bus_context_new_test (test_data_dir, filename);
|
2003-03-31 08:19:50 +00:00
|
|
|
if (context == NULL)
|
|
|
|
|
return FALSE;
|
2003-03-14 01:27:58 +00:00
|
|
|
|
2006-10-01 15:36:19 +00:00
|
|
|
foo = dbus_connection_open_private ("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");
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
spin_connection_until_authenticated (context, foo);
|
|
|
|
|
|
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_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
2003-09-21 19:53:56 +00:00
|
|
|
|
2004-09-17 09:14:49 +00:00
|
|
|
if (!check_double_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("double hello message failed");
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
if (!check_add_match_all (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("AddMatch message failed");
|
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
|
|
|
|
2006-10-01 15:36:19 +00:00
|
|
|
bar = dbus_connection_open_private ("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");
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
spin_connection_until_authenticated (context, bar);
|
|
|
|
|
|
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_hello_message (context, bar))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
if (!check_add_match_all (context, bar))
|
|
|
|
|
_dbus_assert_not_reached ("AddMatch message failed");
|
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
|
|
|
|
2006-10-01 15:36:19 +00:00
|
|
|
baz = dbus_connection_open_private ("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
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
spin_connection_until_authenticated (context, baz);
|
|
|
|
|
|
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-09-21 19:53:56 +00:00
|
|
|
if (!check_add_match_all (context, baz))
|
|
|
|
|
_dbus_assert_not_reached ("AddMatch message failed");
|
2004-07-19 20:55:58 +00:00
|
|
|
|
|
|
|
|
if (!check_get_connection_unix_user (context, baz))
|
|
|
|
|
_dbus_assert_not_reached ("GetConnectionUnixUser message failed");
|
|
|
|
|
|
|
|
|
|
if (!check_get_connection_unix_process_id (context, baz))
|
|
|
|
|
_dbus_assert_not_reached ("GetConnectionUnixProcessID message failed");
|
2006-07-14 01:17:59 +00:00
|
|
|
|
2007-07-26 23:01:14 +00:00
|
|
|
if (!check_list_services (context, baz))
|
|
|
|
|
_dbus_assert_not_reached ("ListActivatableNames message failed");
|
2003-09-21 19:53:56 +00:00
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!check_no_leftovers (context))
|
|
|
|
|
{
|
2006-10-23 17:25:52 +00:00
|
|
|
_dbus_warn ("Messages were left over after setting up initial connections\n");
|
2003-04-14 02:29:21 +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",
|
2003-04-11 03:45:40 +00:00
|
|
|
check_hello_connection);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2005-01-21 03:44:10 +00:00
|
|
|
check2_try_iterations (context, foo, "nonexistent_service_no_auto_start",
|
|
|
|
|
check_nonexistent_service_no_auto_start);
|
2003-04-02 20:14:52 +00:00
|
|
|
|
2007-03-08 08:30:17 +00:00
|
|
|
#ifdef DBUS_WIN_FIXME
|
|
|
|
|
_dbus_warn("TODO: dispatch.c segfault_service_no_auto_start test\n");
|
|
|
|
|
#else
|
2007-07-26 23:01:14 +00:00
|
|
|
check2_try_iterations (context, foo, "segfault_service_no_auto_start",
|
|
|
|
|
check_segfault_service_no_auto_start);
|
2007-03-08 08:30:17 +00:00
|
|
|
#endif
|
2003-04-11 03:45:40 +00:00
|
|
|
|
2005-01-21 03:44:10 +00:00
|
|
|
check2_try_iterations (context, foo, "existent_service_no_auto_start",
|
|
|
|
|
check_existent_service_no_auto_start);
|
2003-03-17 03:09:31 +00:00
|
|
|
|
2005-01-21 03:44:10 +00:00
|
|
|
check2_try_iterations (context, foo, "nonexistent_service_auto_start",
|
2005-07-14 20:44:15 +00:00
|
|
|
check_nonexistent_service_auto_start);
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2007-03-08 08:30:17 +00:00
|
|
|
|
|
|
|
|
#ifdef DBUS_WIN_FIXME
|
|
|
|
|
_dbus_warn("TODO: dispatch.c segfault_service_auto_start test\n");
|
|
|
|
|
#else
|
2007-07-24 12:39:30 +00:00
|
|
|
/* only do the segfault test if we are not using the launcher */
|
2007-07-26 23:01:14 +00:00
|
|
|
check2_try_iterations (context, foo, "segfault_service_auto_start",
|
|
|
|
|
check_segfault_service_auto_start);
|
2007-03-08 08:30:17 +00:00
|
|
|
#endif
|
2005-07-14 20:44:15 +00:00
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
/* only do the shell fail test if we are not using the launcher */
|
2007-07-24 22:11:00 +00:00
|
|
|
check2_try_iterations (context, foo, "shell_fail_service_auto_start",
|
|
|
|
|
check_shell_fail_service_auto_start);
|
2007-07-24 12:39:30 +00:00
|
|
|
|
|
|
|
|
/* specific to launcher */
|
|
|
|
|
if (use_launcher)
|
|
|
|
|
if (!check_launch_service_file_missing (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("did not get service file not found error");
|
2004-03-16 18:00:35 +00:00
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* Note: need to resolve some issues with the testing code in order to run
|
|
|
|
|
* this in oom (handle that we sometimes don't get replies back from the bus
|
|
|
|
|
* when oom happens, without blocking the test).
|
|
|
|
|
*/
|
2005-01-21 03:44:10 +00:00
|
|
|
check2_try_iterations (context, foo, "existent_service_auto_auto_start",
|
2005-07-14 20:44:15 +00:00
|
|
|
check_existent_service_auto_start);
|
2004-03-16 18:00:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
2007-07-26 23:01:14 +00:00
|
|
|
if (!check_existent_service_auto_start (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("existent service auto start failed");
|
2004-03-16 18:00:35 +00:00
|
|
|
|
2007-07-26 23:01:14 +00:00
|
|
|
if (!check_shell_service_success_auto_start (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("shell success service auto start failed");
|
2005-07-14 20:44:15 +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
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_dispatch_test_conf_fail (const DBusString *test_data_dir,
|
|
|
|
|
const char *filename)
|
|
|
|
|
{
|
|
|
|
|
BusContext *context;
|
|
|
|
|
DBusConnection *foo;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
/* save the config name for the activation helper */
|
2007-07-24 22:11:00 +00:00
|
|
|
if (!setenv_TEST_LAUNCH_HELPER_CONFIG (test_data_dir, filename))
|
|
|
|
|
_dbus_assert_not_reached ("no memory setting TEST_LAUNCH_HELPER_CONFIG");
|
|
|
|
|
|
2007-07-24 12:39:30 +00:00
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
|
|
|
|
context = bus_context_new_test (test_data_dir, filename);
|
|
|
|
|
if (context == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
foo = dbus_connection_open_private ("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");
|
|
|
|
|
|
|
|
|
|
spin_connection_until_authenticated (context, foo);
|
|
|
|
|
|
|
|
|
|
if (!check_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
|
|
|
|
|
|
|
|
|
if (!check_double_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("double hello message failed");
|
|
|
|
|
|
|
|
|
|
if (!check_add_match_all (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("AddMatch message failed");
|
|
|
|
|
|
|
|
|
|
/* this only tests the activation.c user check */
|
|
|
|
|
if (!check_launch_service_user_missing (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("user missing did not trigger error");
|
|
|
|
|
|
|
|
|
|
/* this only tests the desktop.c exec check */
|
|
|
|
|
if (!check_launch_service_exec_missing (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("exec missing did not trigger error");
|
|
|
|
|
|
|
|
|
|
/* this only tests the desktop.c service check */
|
|
|
|
|
if (!check_launch_service_service_missing (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("service missing did not trigger error");
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Disconnecting foo\n");
|
|
|
|
|
|
|
|
|
|
kill_client_connection_unchecked (foo);
|
|
|
|
|
|
|
|
|
|
bus_context_unref (context);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_dispatch_test (const DBusString *test_data_dir)
|
|
|
|
|
{
|
|
|
|
|
/* run normal activation tests */
|
|
|
|
|
_dbus_verbose ("Normal activation tests\n");
|
|
|
|
|
if (!bus_dispatch_test_conf (test_data_dir,
|
|
|
|
|
"valid-config-files/debug-allow-all.conf", FALSE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* run launch-helper activation tests */
|
|
|
|
|
_dbus_verbose ("Launch helper activation tests\n");
|
|
|
|
|
if (!bus_dispatch_test_conf (test_data_dir,
|
|
|
|
|
"valid-config-files-system/debug-allow-all-pass.conf", TRUE))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* run select launch-helper activation tests on broken service files */
|
|
|
|
|
if (!bus_dispatch_test_conf_fail (test_data_dir,
|
|
|
|
|
"valid-config-files-system/debug-allow-all-fail.conf"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2006-10-01 15:36:19 +00:00
|
|
|
foo = dbus_connection_open_private ("debug-pipe:name=test-server", &error);
|
2003-04-14 23:52:40 +00:00
|
|
|
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");
|
|
|
|
|
|
2004-11-25 Havoc Pennington <hp@redhat.com>
The primary change here is to always write() once before adding
the write watch, which gives us about a 10% performance increase.
* dbus/dbus-transport-unix.c: a number of modifications to cope
with removing messages_pending
(check_write_watch): properly handle
DBUS_AUTH_STATE_WAITING_FOR_MEMORY; adapt to removal of
messages_pending stuff
(check_read_watch): properly handle WAITING_FOR_MEMORY and
AUTHENTICATED cases
(unix_handle_watch): after writing, see if the write watch can be
removed
(unix_do_iteration): assert that write_watch/read_watch are
non-NULL rather than testing that they aren't, since they
aren't allowed to be NULL. check_write_watch() at the end so
we add the watch if we did not finish writing (e.g. got EAGAIN)
* dbus/dbus-transport-protected.h: remove messages_pending call,
since it resulted in too much inefficient watch adding/removing;
instead we now require that the transport user does an iteration
after queueing outgoing messages, and after trying the first
write() we add a write watch if we got EAGAIN or exceeded our
max bytes to write per iteration setting
* dbus/dbus-string.c (_dbus_string_validate_signature): add this
function
* dbus/dbus-server-unix.c (unix_finalize): the socket name was
freed and then accessed, valgrind flagged this bug, fix it
* dbus/dbus-message.c: fix several bugs where HEADER_FIELD_LAST was taken
as the last valid field plus 1, where really it is equal to the
last valid field. Corrects some message corruption issues.
* dbus/dbus-mainloop.c: verbosity changes
* dbus/dbus-keyring.c (_dbus_keyring_new_homedir): handle OOM
instead of aborting in one of the test codepaths
* dbus/dbus-internals.c (_dbus_verbose_real): fix a bug that
caused not printing the pid ever again if a verbose was missing
the newline at the end
(_dbus_header_field_to_string): add HEADER_FIELD_SIGNATURE
* dbus/dbus-connection.c: verbosity changes;
(dbus_connection_has_messages_to_send): new function
(_dbus_connection_message_sent): no longer call transport->messages_pending
(_dbus_connection_send_preallocated_unlocked): do one iteration to
try to write() immediately, so we can avoid the write watch. This
is the core purpose of this patchset
(_dbus_connection_get_dispatch_status_unlocked): if disconnected,
dump the outgoing message queue, so nobody will get confused
trying to send them or thinking stuff is pending to be sent
* bus/test.c: verbosity changes
* bus/driver.c: verbosity/assertion changes
* bus/dispatch.c: a bunch of little tweaks to get it working again
because this patchset changes when/where you need to block.
2004-11-26 01:53:13 +00:00
|
|
|
spin_connection_until_authenticated (context, foo);
|
|
|
|
|
|
2003-04-14 23:52:40 +00:00
|
|
|
if (!check_hello_message (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("hello message failed");
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
if (!check_add_match_all (context, foo))
|
|
|
|
|
_dbus_assert_not_reached ("addmatch message failed");
|
|
|
|
|
|
2003-04-14 23:52:40 +00:00
|
|
|
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 */
|