2007-07-14 02:44:01 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2003-01-06 01:08:14 +00:00
|
|
|
/* connection.c Client connections
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2003 Red Hat, Inc.
|
|
|
|
|
*
|
2004-08-10 03:07:01 +00:00
|
|
|
* Licensed under the Academic Free License version 2.1
|
2003-01-06 01:08:14 +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-06 01:08:14 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#include "connection.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 "dispatch.h"
|
2003-03-23 07:41:54 +00:00
|
|
|
#include "policy.h"
|
2003-01-06 01:08:14 +00:00
|
|
|
#include "services.h"
|
2003-03-13 00:56:43 +00:00
|
|
|
#include "utils.h"
|
2003-09-21 19:53:56 +00:00
|
|
|
#include "signals.h"
|
2003-10-11 06:20:28 +00:00
|
|
|
#include "expirelist.h"
|
2004-07-30 05:59:34 +00:00
|
|
|
#include "selinux.h"
|
2003-01-06 01:08:14 +00:00
|
|
|
#include <dbus/dbus-list.h>
|
2003-04-19 16:16:24 +00:00
|
|
|
#include <dbus/dbus-hash.h>
|
2003-04-24 21:26:25 +00:00
|
|
|
#include <dbus/dbus-timeout.h>
|
2003-01-06 01:08:14 +00:00
|
|
|
|
2008-12-17 16:01:28 -05:00
|
|
|
/* Trim executed commands to this length; we want to keep logs readable */
|
|
|
|
|
#define MAX_LOG_COMMAND_LEN 50
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
static void bus_connection_remove_transactions (DBusConnection *connection);
|
|
|
|
|
|
2003-10-12 05:59:39 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
BusExpireItem expire_item;
|
|
|
|
|
|
|
|
|
|
DBusConnection *will_get_reply;
|
|
|
|
|
DBusConnection *will_send_reply;
|
|
|
|
|
|
|
|
|
|
dbus_uint32_t reply_serial;
|
|
|
|
|
|
|
|
|
|
} BusPendingReply;
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
struct BusConnections
|
|
|
|
|
{
|
|
|
|
|
int refcount;
|
2003-04-19 16:16:24 +00:00
|
|
|
DBusList *completed; /**< List of all completed connections */
|
|
|
|
|
int n_completed; /**< Length of completed list */
|
|
|
|
|
DBusList *incomplete; /**< List of all not-yet-active connections */
|
|
|
|
|
int n_incomplete; /**< Length of incomplete list */
|
2003-03-13 03:52:58 +00:00
|
|
|
BusContext *context;
|
2003-04-19 16:16:24 +00:00
|
|
|
DBusHashTable *completed_by_user; /**< Number of completed connections for each UID */
|
2003-04-24 21:26:25 +00:00
|
|
|
DBusTimeout *expire_timeout; /**< Timeout for expiring incomplete connections. */
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
int stamp; /**< Incrementing number */
|
2003-10-14 05:16:56 +00:00
|
|
|
BusExpireList *pending_replies; /**< List of pending replies */
|
2003-03-13 03:52:58 +00:00
|
|
|
};
|
|
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
static dbus_int32_t connection_data_slot = -1;
|
2003-01-06 01:08:14 +00:00
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2003-03-13 03:52:58 +00:00
|
|
|
BusConnections *connections;
|
2003-04-19 16:16:24 +00:00
|
|
|
DBusList *link_in_connection_list;
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusConnection *connection;
|
2003-01-06 01:08:14 +00:00
|
|
|
DBusList *services_owned;
|
2003-04-25 23:50:34 +00:00
|
|
|
int n_services_owned;
|
2003-09-21 19:53:56 +00:00
|
|
|
DBusList *match_rules;
|
|
|
|
|
int n_match_rules;
|
2003-01-21 12:42:33 +00:00
|
|
|
char *name;
|
2003-03-13 00:56:43 +00:00
|
|
|
DBusList *transaction_messages; /**< Stuff we need to send as part of a transaction */
|
|
|
|
|
DBusMessage *oom_message;
|
|
|
|
|
DBusPreallocatedSend *oom_preallocated;
|
2003-04-12 18:32:11 +00:00
|
|
|
BusClientPolicy *policy;
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2008-12-17 16:01:28 -05:00
|
|
|
char *cached_loginfo_string;
|
2004-07-30 05:59:34 +00:00
|
|
|
BusSELinuxID *selinux_id;
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
long connection_tv_sec; /**< Time when we connected (seconds component) */
|
|
|
|
|
long connection_tv_usec; /**< Time when we connected (microsec component) */
|
2003-09-21 19:53:56 +00:00
|
|
|
int stamp; /**< connections->stamp last time we were traversed */
|
2003-01-06 01:08:14 +00:00
|
|
|
} BusConnectionData;
|
|
|
|
|
|
2003-10-28 23:51:24 +00:00
|
|
|
static dbus_bool_t bus_pending_reply_expired (BusExpireList *list,
|
|
|
|
|
DBusList *link,
|
|
|
|
|
void *data);
|
2003-10-14 05:16:56 +00:00
|
|
|
|
|
|
|
|
static void bus_connection_drop_pending_replies (BusConnections *connections,
|
|
|
|
|
DBusConnection *connection);
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
static dbus_bool_t expire_incomplete_timeout (void *data);
|
|
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
#define BUS_CONNECTION_DATA(connection) (dbus_connection_get_data ((connection), connection_data_slot))
|
|
|
|
|
|
2003-04-06 23:53:27 +00:00
|
|
|
static DBusLoop*
|
2003-04-04 00:39:22 +00:00
|
|
|
connection_get_loop (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
return bus_context_get_loop (d->connections->context);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
get_connections_for_uid (BusConnections *connections,
|
|
|
|
|
dbus_uid_t uid)
|
|
|
|
|
{
|
|
|
|
|
void *val;
|
|
|
|
|
int current_count;
|
|
|
|
|
|
|
|
|
|
/* val is NULL is 0 when it isn't in the hash yet */
|
|
|
|
|
|
|
|
|
|
val = _dbus_hash_table_lookup_ulong (connections->completed_by_user,
|
|
|
|
|
uid);
|
|
|
|
|
|
|
|
|
|
current_count = _DBUS_POINTER_TO_INT (val);
|
|
|
|
|
|
|
|
|
|
return current_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
adjust_connections_for_uid (BusConnections *connections,
|
|
|
|
|
dbus_uid_t uid,
|
|
|
|
|
int adjustment)
|
|
|
|
|
{
|
|
|
|
|
int current_count;
|
|
|
|
|
|
|
|
|
|
current_count = get_connections_for_uid (connections, uid);
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Adjusting connection count for UID " DBUS_UID_FORMAT
|
|
|
|
|
": was %d adjustment %d making %d\n",
|
|
|
|
|
uid, current_count, adjustment, current_count + adjustment);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (current_count >= 0);
|
|
|
|
|
|
|
|
|
|
current_count += adjustment;
|
|
|
|
|
|
|
|
|
|
_dbus_assert (current_count >= 0);
|
|
|
|
|
|
|
|
|
|
if (current_count == 0)
|
|
|
|
|
{
|
|
|
|
|
_dbus_hash_table_remove_ulong (connections->completed_by_user, uid);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dbus_bool_t retval;
|
|
|
|
|
|
|
|
|
|
retval = _dbus_hash_table_insert_ulong (connections->completed_by_user,
|
|
|
|
|
uid, _DBUS_INT_TO_POINTER (current_count));
|
|
|
|
|
|
|
|
|
|
/* only positive adjustment can fail as otherwise
|
|
|
|
|
* a hash entry should already exist
|
|
|
|
|
*/
|
|
|
|
|
_dbus_assert (adjustment > 0 ||
|
|
|
|
|
(adjustment <= 0 && retval));
|
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-15 16:25:08 +00:00
|
|
|
void
|
2003-03-13 00:56:43 +00:00
|
|
|
bus_connection_disconnected (DBusConnection *connection)
|
2003-01-06 01:08:14 +00:00
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
BusService *service;
|
2003-09-21 19:53:56 +00:00
|
|
|
BusMatchmaker *matchmaker;
|
|
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
2003-03-16 21:01:57 +00:00
|
|
|
_dbus_assert (d != NULL);
|
2003-01-06 01:08:14 +00:00
|
|
|
|
2003-03-16 21:01:57 +00:00
|
|
|
_dbus_verbose ("%s disconnected, dropping all service ownership and releasing\n",
|
|
|
|
|
d->name ? d->name : "(inactive)");
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
/* Delete our match rules */
|
|
|
|
|
if (d->n_match_rules > 0)
|
|
|
|
|
{
|
|
|
|
|
matchmaker = bus_context_get_matchmaker (d->connections->context);
|
|
|
|
|
bus_matchmaker_disconnected (matchmaker, connection);
|
|
|
|
|
}
|
2003-03-16 21:01:57 +00:00
|
|
|
|
2006-09-11 17:41:21 +00:00
|
|
|
/* Drop any service ownership. Unfortunately, this requires
|
2003-03-13 00:56:43 +00:00
|
|
|
* memory allocation and there doesn't seem to be a good way to
|
|
|
|
|
* handle it other than sleeping; we can't "fail" the operation of
|
|
|
|
|
* disconnecting a client, and preallocating a broadcast "service is
|
|
|
|
|
* now gone" message for every client-service pair seems kind of
|
2006-09-11 17:41:21 +00:00
|
|
|
* involved.
|
2003-03-13 00:56:43 +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
|
|
|
while ((service = _dbus_list_get_last (&d->services_owned)))
|
|
|
|
|
{
|
|
|
|
|
BusTransaction *transaction;
|
|
|
|
|
DBusError error;
|
|
|
|
|
|
|
|
|
|
retry:
|
|
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
|
2005-08-03 17:42:56 +00:00
|
|
|
while ((transaction = bus_transaction_new (d->connections->context)) == NULL)
|
|
|
|
|
_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
|
|
|
|
|
|
|
|
if (!bus_service_remove_owner (service, connection,
|
|
|
|
|
transaction, &error))
|
|
|
|
|
{
|
2003-04-11 00:03:06 +00:00
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (&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
|
|
|
if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
bus_transaction_cancel_and_free (transaction);
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
2003-04-11 00:03:06 +00:00
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Failed to remove service owner: %s %s\n",
|
|
|
|
|
error.name, error.message);
|
|
|
|
|
_dbus_assert_not_reached ("Removing service owner failed for non-memory-related reason");
|
|
|
|
|
}
|
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_transaction_execute_and_free (transaction);
|
|
|
|
|
}
|
2003-01-06 01:08:14 +00:00
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
bus_dispatch_remove_connection (connection);
|
2003-01-21 12:42:33 +00:00
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
/* no more watching */
|
2003-03-14 01:27:58 +00:00
|
|
|
if (!dbus_connection_set_watch_functions (connection,
|
2003-03-15 20:47:16 +00:00
|
|
|
NULL, NULL, NULL,
|
2003-03-14 01:27:58 +00:00
|
|
|
connection,
|
|
|
|
|
NULL))
|
|
|
|
|
_dbus_assert_not_reached ("setting watch functions to NULL failed");
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_set_timeout_functions (connection,
|
2003-03-15 20:47:16 +00:00
|
|
|
NULL, NULL, NULL,
|
2003-03-14 01:27:58 +00:00
|
|
|
connection,
|
|
|
|
|
NULL))
|
|
|
|
|
_dbus_assert_not_reached ("setting timeout functions to NULL failed");
|
|
|
|
|
|
2003-03-24 17:30:47 +00:00
|
|
|
dbus_connection_set_unix_user_function (connection,
|
|
|
|
|
NULL, NULL, NULL);
|
2007-06-09 23:41:33 +00:00
|
|
|
dbus_connection_set_windows_user_function (connection,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
2003-04-09 22:15:05 +00:00
|
|
|
dbus_connection_set_dispatch_status_function (connection,
|
|
|
|
|
NULL, NULL, NULL);
|
2003-03-24 17:30:47 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
bus_connection_remove_transactions (connection);
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
if (d->link_in_connection_list != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (d->name != NULL)
|
|
|
|
|
{
|
|
|
|
|
unsigned long uid;
|
|
|
|
|
|
|
|
|
|
_dbus_list_remove_link (&d->connections->completed, d->link_in_connection_list);
|
|
|
|
|
d->link_in_connection_list = NULL;
|
|
|
|
|
d->connections->n_completed -= 1;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
if (dbus_connection_get_unix_user (connection, &uid))
|
|
|
|
|
{
|
|
|
|
|
if (!adjust_connections_for_uid (d->connections,
|
|
|
|
|
uid, -1))
|
|
|
|
|
_dbus_assert_not_reached ("adjusting downward should never fail");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_list_remove_link (&d->connections->incomplete, d->link_in_connection_list);
|
|
|
|
|
d->link_in_connection_list = NULL;
|
|
|
|
|
d->connections->n_incomplete -= 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d->connections->n_incomplete >= 0);
|
|
|
|
|
_dbus_assert (d->connections->n_completed >= 0);
|
|
|
|
|
}
|
2003-10-14 05:16:56 +00:00
|
|
|
|
|
|
|
|
bus_connection_drop_pending_replies (d->connections, connection);
|
2003-04-19 16:16:24 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
/* frees "d" as side effect */
|
2003-01-06 01:08:14 +00:00
|
|
|
dbus_connection_set_data (connection,
|
|
|
|
|
connection_data_slot,
|
|
|
|
|
NULL, NULL);
|
2003-10-14 05:16:56 +00:00
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-17 01:54:37 +00:00
|
|
|
static dbus_bool_t
|
2003-01-06 01:08:14 +00:00
|
|
|
connection_watch_callback (DBusWatch *watch,
|
|
|
|
|
unsigned int condition,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
2003-04-18 04:18:57 +00:00
|
|
|
/* FIXME this can be done in dbus-mainloop.c
|
2003-05-11 07:59:08 +00:00
|
|
|
* if the code in activation.c for the babysitter
|
|
|
|
|
* watch handler is fixed.
|
|
|
|
|
*/
|
2003-04-18 04:18:57 +00:00
|
|
|
|
2003-04-10 05:12:19 +00:00
|
|
|
#if 0
|
|
|
|
|
_dbus_verbose ("Calling handle_watch\n");
|
|
|
|
|
#endif
|
2003-04-18 04:18:57 +00:00
|
|
|
return dbus_watch_handle (watch, condition);
|
2003-01-06 01:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
static dbus_bool_t
|
2003-01-06 01:08:14 +00:00
|
|
|
add_connection_watch (DBusWatch *watch,
|
2003-04-04 00:39:22 +00:00
|
|
|
void *data)
|
2003-01-06 01:08:14 +00:00
|
|
|
{
|
2003-04-04 00:39:22 +00:00
|
|
|
DBusConnection *connection = data;
|
|
|
|
|
|
2003-04-06 23:53:27 +00:00
|
|
|
return _dbus_loop_add_watch (connection_get_loop (connection),
|
|
|
|
|
watch, connection_watch_callback, connection,
|
|
|
|
|
NULL);
|
2003-01-06 01:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
remove_connection_watch (DBusWatch *watch,
|
2003-04-04 00:39:22 +00:00
|
|
|
void *data)
|
2003-01-06 01:08:14 +00:00
|
|
|
{
|
2003-04-04 00:39:22 +00:00
|
|
|
DBusConnection *connection = data;
|
|
|
|
|
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_loop_remove_watch (connection_get_loop (connection),
|
|
|
|
|
watch, connection_watch_callback, connection);
|
2003-01-06 01:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
static void
|
|
|
|
|
connection_timeout_callback (DBusTimeout *timeout,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
2003-04-18 04:18:57 +00:00
|
|
|
/* DBusConnection *connection = data; */
|
2003-03-15 02:19:02 +00:00
|
|
|
|
2003-03-17 01:54:37 +00:00
|
|
|
/* can return FALSE on OOM but we just let it fire again later */
|
2003-03-14 01:27:58 +00:00
|
|
|
dbus_timeout_handle (timeout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
add_connection_timeout (DBusTimeout *timeout,
|
2003-04-04 00:39:22 +00:00
|
|
|
void *data)
|
2003-03-14 01:27:58 +00:00
|
|
|
{
|
2003-04-04 00:39:22 +00:00
|
|
|
DBusConnection *connection = data;
|
|
|
|
|
|
2003-04-06 23:53:27 +00:00
|
|
|
return _dbus_loop_add_timeout (connection_get_loop (connection),
|
|
|
|
|
timeout, connection_timeout_callback, connection, NULL);
|
2003-03-14 01:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
remove_connection_timeout (DBusTimeout *timeout,
|
2003-04-04 00:39:22 +00:00
|
|
|
void *data)
|
2003-03-14 01:27:58 +00:00
|
|
|
{
|
2003-04-04 00:39:22 +00:00
|
|
|
DBusConnection *connection = data;
|
|
|
|
|
|
2003-04-06 23:53:27 +00:00
|
|
|
_dbus_loop_remove_timeout (connection_get_loop (connection),
|
|
|
|
|
timeout, connection_timeout_callback, connection);
|
2003-03-14 01:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-09 22:15:05 +00:00
|
|
|
static void
|
|
|
|
|
dispatch_status_function (DBusConnection *connection,
|
|
|
|
|
DBusDispatchStatus new_status,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
DBusLoop *loop = data;
|
|
|
|
|
|
|
|
|
|
if (new_status != DBUS_DISPATCH_COMPLETE)
|
|
|
|
|
{
|
|
|
|
|
while (!_dbus_loop_queue_dispatch (loop, connection))
|
|
|
|
|
_dbus_wait_for_memory ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-23 07:41:54 +00:00
|
|
|
static dbus_bool_t
|
2007-06-09 23:41:33 +00:00
|
|
|
allow_unix_user_function (DBusConnection *connection,
|
|
|
|
|
unsigned long uid,
|
|
|
|
|
void *data)
|
2003-03-23 07:41:54 +00:00
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
2007-06-09 23:41:33 +00:00
|
|
|
return bus_context_allow_unix_user (d->connections->context, uid);
|
2003-03-23 07:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
static void
|
|
|
|
|
free_connection_data (void *data)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d = data;
|
|
|
|
|
|
|
|
|
|
/* services_owned should be NULL since we should be disconnected */
|
|
|
|
|
_dbus_assert (d->services_owned == NULL);
|
2003-04-25 23:50:34 +00:00
|
|
|
_dbus_assert (d->n_services_owned == 0);
|
2003-03-13 00:56:43 +00:00
|
|
|
/* similarly */
|
|
|
|
|
_dbus_assert (d->transaction_messages == NULL);
|
2003-01-21 12:42:33 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (d->oom_preallocated)
|
|
|
|
|
dbus_connection_free_preallocated_send (d->connection, d->oom_preallocated);
|
2003-03-17 05:39:10 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (d->oom_message)
|
|
|
|
|
dbus_message_unref (d->oom_message);
|
2003-03-23 07:41:54 +00:00
|
|
|
|
|
|
|
|
if (d->policy)
|
2003-04-12 18:32:11 +00:00
|
|
|
bus_client_policy_unref (d->policy);
|
2004-07-30 05:59:34 +00:00
|
|
|
|
|
|
|
|
if (d->selinux_id)
|
|
|
|
|
bus_selinux_id_unref (d->selinux_id);
|
2003-03-23 07:41:54 +00:00
|
|
|
|
2008-12-17 16:01:28 -05:00
|
|
|
dbus_free (d->cached_loginfo_string);
|
|
|
|
|
|
2003-01-21 12:42:33 +00:00
|
|
|
dbus_free (d->name);
|
2003-01-06 01:08:14 +00:00
|
|
|
|
|
|
|
|
dbus_free (d);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
static void
|
|
|
|
|
call_timeout_callback (DBusTimeout *timeout,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
/* can return FALSE on OOM but we just let it fire again later */
|
|
|
|
|
dbus_timeout_handle (timeout);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
BusConnections*
|
|
|
|
|
bus_connections_new (BusContext *context)
|
2003-01-06 01:08:14 +00:00
|
|
|
{
|
2003-03-13 03:52:58 +00:00
|
|
|
BusConnections *connections;
|
2003-01-06 01:08:14 +00:00
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
if (!dbus_connection_allocate_data_slot (&connection_data_slot))
|
2003-04-24 21:26:25 +00:00
|
|
|
goto failed_0;
|
2003-01-06 01:08:14 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
connections = dbus_new0 (BusConnections, 1);
|
|
|
|
|
if (connections == NULL)
|
2003-04-24 21:26:25 +00:00
|
|
|
goto failed_1;
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_ULONG,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
if (connections->completed_by_user == NULL)
|
2003-04-24 21:26:25 +00:00
|
|
|
goto failed_2;
|
|
|
|
|
|
|
|
|
|
connections->expire_timeout = _dbus_timeout_new (100, /* irrelevant */
|
|
|
|
|
expire_incomplete_timeout,
|
|
|
|
|
connections, NULL);
|
|
|
|
|
if (connections->expire_timeout == NULL)
|
|
|
|
|
goto failed_3;
|
|
|
|
|
|
|
|
|
|
_dbus_timeout_set_enabled (connections->expire_timeout, FALSE);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
connections->pending_replies = bus_expire_list_new (bus_context_get_loop (context),
|
|
|
|
|
bus_context_get_reply_timeout (context),
|
|
|
|
|
bus_pending_reply_expired,
|
|
|
|
|
connections);
|
|
|
|
|
if (connections->pending_replies == NULL)
|
|
|
|
|
goto failed_4;
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
if (!_dbus_loop_add_timeout (bus_context_get_loop (context),
|
|
|
|
|
connections->expire_timeout,
|
|
|
|
|
call_timeout_callback, NULL, NULL))
|
2003-10-14 05:16:56 +00:00
|
|
|
goto failed_5;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
|
|
|
|
connections->refcount = 1;
|
|
|
|
|
connections->context = context;
|
|
|
|
|
|
|
|
|
|
return connections;
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
failed_5:
|
|
|
|
|
bus_expire_list_free (connections->pending_replies);
|
2003-04-24 21:26:25 +00:00
|
|
|
failed_4:
|
|
|
|
|
_dbus_timeout_unref (connections->expire_timeout);
|
|
|
|
|
failed_3:
|
|
|
|
|
_dbus_hash_table_unref (connections->completed_by_user);
|
|
|
|
|
failed_2:
|
|
|
|
|
dbus_free (connections);
|
|
|
|
|
failed_1:
|
2003-06-22 19:39:47 +00:00
|
|
|
dbus_connection_free_data_slot (&connection_data_slot);
|
2003-04-24 21:26:25 +00:00
|
|
|
failed_0:
|
|
|
|
|
return NULL;
|
2003-03-13 03:52:58 +00:00
|
|
|
}
|
|
|
|
|
|
2003-11-27 01:25:50 +00:00
|
|
|
BusConnections *
|
2003-03-13 03:52:58 +00:00
|
|
|
bus_connections_ref (BusConnections *connections)
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (connections->refcount > 0);
|
|
|
|
|
connections->refcount += 1;
|
2003-11-27 01:25:50 +00:00
|
|
|
|
|
|
|
|
return connections;
|
2003-03-13 03:52:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_connections_unref (BusConnections *connections)
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (connections->refcount > 0);
|
|
|
|
|
connections->refcount -= 1;
|
|
|
|
|
if (connections->refcount == 0)
|
|
|
|
|
{
|
2003-04-19 16:16:24 +00:00
|
|
|
/* drop all incomplete */
|
|
|
|
|
while (connections->incomplete != 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
|
|
|
{
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
connection = connections->incomplete->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
|
|
|
|
|
|
|
|
dbus_connection_ref (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
|
|
|
bus_connection_disconnected (connection);
|
|
|
|
|
dbus_connection_unref (connection);
|
|
|
|
|
}
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (connections->n_incomplete == 0);
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
/* drop all real connections */
|
|
|
|
|
while (connections->completed != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
|
|
|
|
|
connection = connections->completed->data;
|
|
|
|
|
|
|
|
|
|
dbus_connection_ref (connection);
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (connection);
|
2003-04-19 16:16:24 +00:00
|
|
|
bus_connection_disconnected (connection);
|
2003-10-14 05:16:56 +00:00
|
|
|
dbus_connection_unref (connection);
|
2003-04-19 16:16:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_dbus_assert (connections->n_completed == 0);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
bus_expire_list_free (connections->pending_replies);
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
_dbus_loop_remove_timeout (bus_context_get_loop (connections->context),
|
|
|
|
|
connections->expire_timeout,
|
|
|
|
|
call_timeout_callback, NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_timeout_unref (connections->expire_timeout);
|
|
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
_dbus_hash_table_unref (connections->completed_by_user);
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
dbus_free (connections);
|
|
|
|
|
|
2003-06-22 19:39:47 +00:00
|
|
|
dbus_connection_free_data_slot (&connection_data_slot);
|
2003-03-13 03:52:58 +00:00
|
|
|
}
|
2003-01-06 01:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-17 16:01:28 -05:00
|
|
|
/* Used for logging */
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
cache_peer_loginfo_string (BusConnectionData *d,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusString loginfo_buf;
|
|
|
|
|
unsigned long uid;
|
|
|
|
|
unsigned long pid;
|
|
|
|
|
char *windows_sid;
|
|
|
|
|
dbus_bool_t prev_added;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_init (&loginfo_buf))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
prev_added = FALSE;
|
|
|
|
|
if (dbus_connection_get_unix_user (connection, &uid))
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_string_append_printf (&loginfo_buf, "uid=%ld", uid))
|
|
|
|
|
goto oom;
|
|
|
|
|
else
|
|
|
|
|
prev_added = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_connection_get_unix_process_id (connection, &pid))
|
|
|
|
|
{
|
|
|
|
|
if (prev_added)
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_string_append_byte (&loginfo_buf, ' '))
|
|
|
|
|
goto oom;
|
|
|
|
|
}
|
|
|
|
|
if (!_dbus_string_append_printf (&loginfo_buf, "pid=%ld comm=\"", pid))
|
|
|
|
|
goto oom;
|
2009-03-12 10:31:54 -04:00
|
|
|
/* Ignore errors here; we may not have permissions to read the
|
|
|
|
|
* proc file. */
|
|
|
|
|
_dbus_command_for_pid (pid, &loginfo_buf, MAX_LOG_COMMAND_LEN, NULL);
|
|
|
|
|
if (!_dbus_string_append_byte (&loginfo_buf, '"'))
|
|
|
|
|
goto oom;
|
2008-12-17 16:01:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_connection_get_windows_user (connection, &windows_sid))
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_string_append_printf (&loginfo_buf, "sid=\"%s\" ", windows_sid))
|
|
|
|
|
goto oom;
|
|
|
|
|
dbus_free (windows_sid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_steal_data (&loginfo_buf, &(d->cached_loginfo_string)))
|
|
|
|
|
goto oom;
|
|
|
|
|
|
|
|
|
|
_dbus_string_free (&loginfo_buf);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
oom:
|
|
|
|
|
_dbus_string_free (&loginfo_buf);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
dbus_bool_t
|
2003-03-13 03:52:58 +00:00
|
|
|
bus_connections_setup_connection (BusConnections *connections,
|
|
|
|
|
DBusConnection *connection)
|
2003-01-06 01:08:14 +00:00
|
|
|
{
|
2008-12-17 16:01:28 -05:00
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
BusConnectionData *d;
|
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 retval;
|
2004-07-30 05:59:34 +00:00
|
|
|
DBusError error;
|
2008-12-17 16:01:28 -05: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
|
|
|
|
2003-01-14 11:19:06 +00:00
|
|
|
d = dbus_new0 (BusConnectionData, 1);
|
|
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
if (d == NULL)
|
|
|
|
|
return FALSE;
|
2003-03-13 00:56:43 +00:00
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
d->connections = connections;
|
2003-03-13 00:56:43 +00:00
|
|
|
d->connection = connection;
|
2003-05-12 02:44:45 +00:00
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
_dbus_get_current_time (&d->connection_tv_sec,
|
|
|
|
|
&d->connection_tv_usec);
|
|
|
|
|
|
2003-03-17 05:39:10 +00:00
|
|
|
_dbus_assert (connection_data_slot >= 0);
|
2003-01-06 01:08:14 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_set_data (connection,
|
|
|
|
|
connection_data_slot,
|
|
|
|
|
d, free_connection_data))
|
|
|
|
|
{
|
|
|
|
|
dbus_free (d);
|
|
|
|
|
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
|
|
|
|
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
|
|
|
dbus_connection_set_route_peer_messages (connection, 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
|
|
|
retval = FALSE;
|
2004-07-30 05:59:34 +00:00
|
|
|
|
|
|
|
|
dbus_error_init (&error);
|
|
|
|
|
d->selinux_id = bus_selinux_init_connection_id (connection,
|
|
|
|
|
&error);
|
|
|
|
|
if (dbus_error_is_set (&error))
|
|
|
|
|
{
|
|
|
|
|
/* This is a bit bogus because we pretend all errors
|
|
|
|
|
* are OOM; this is done because we know that in bus.c
|
|
|
|
|
* an OOM error disconnects the connection, which is
|
|
|
|
|
* the same thing we want on any other error.
|
|
|
|
|
*/
|
|
|
|
|
dbus_error_free (&error);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
2008-12-17 16:01:28 -05:00
|
|
|
|
2003-03-14 01:27:58 +00:00
|
|
|
if (!dbus_connection_set_watch_functions (connection,
|
2003-04-04 00:39:22 +00:00
|
|
|
add_connection_watch,
|
|
|
|
|
remove_connection_watch,
|
2003-03-15 20:47:16 +00:00
|
|
|
NULL,
|
2003-03-14 01:27:58 +00:00
|
|
|
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
|
|
|
goto out;
|
2003-03-14 01:27:58 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_set_timeout_functions (connection,
|
2003-04-04 00:39:22 +00:00
|
|
|
add_connection_timeout,
|
|
|
|
|
remove_connection_timeout,
|
2003-03-15 20:47:16 +00:00
|
|
|
NULL,
|
2003-03-14 01:27:58 +00:00
|
|
|
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
|
|
|
goto out;
|
2007-06-09 23:41:33 +00:00
|
|
|
|
|
|
|
|
/* For now we don't need to set a Windows user function because
|
|
|
|
|
* there are no policies in the config file controlling what
|
|
|
|
|
* Windows users can connect. The default 'same user that owns the
|
|
|
|
|
* bus can connect' behavior of DBusConnection is fine on Windows.
|
|
|
|
|
*/
|
2003-03-24 17:30:47 +00:00
|
|
|
dbus_connection_set_unix_user_function (connection,
|
2007-06-09 23:41:33 +00:00
|
|
|
allow_unix_user_function,
|
2003-03-24 17:30:47 +00:00
|
|
|
NULL, NULL);
|
2003-04-09 22:15:05 +00:00
|
|
|
|
|
|
|
|
dbus_connection_set_dispatch_status_function (connection,
|
|
|
|
|
dispatch_status_function,
|
|
|
|
|
bus_context_get_loop (connections->context),
|
|
|
|
|
NULL);
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
d->link_in_connection_list = _dbus_list_alloc_link (connection);
|
|
|
|
|
if (d->link_in_connection_list == NULL)
|
|
|
|
|
goto out;
|
2003-01-06 01:08:14 +00:00
|
|
|
|
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* bus/Makefile.am:
* bus/connection.c: (connection_disconnect_handler),
(connection_watch_callback), (bus_connection_setup):
* bus/dispatch.c: (send_one_message),
(bus_dispatch_broadcast_message), (bus_dispatch_message_handler),
(bus_dispatch_add_connection), (bus_dispatch_remove_connection):
* bus/dispatch.h:
* bus/driver.c: (bus_driver_send_service_deleted),
(bus_driver_send_service_created), (bus_driver_handle_hello),
(bus_driver_send_welcome_message),
(bus_driver_handle_list_services), (bus_driver_remove_connection),
(bus_driver_handle_message):
* bus/driver.h:
Refactor code, put the message dispatching in its own file. Use
_DBUS_HANDLE_OOM. Also send ServiceDeleted messages when a client
is disconnected.
2003-01-25 20:53:53 +00:00
|
|
|
/* Setup the connection with the dispatcher */
|
|
|
|
|
if (!bus_dispatch_add_connection (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
|
|
|
goto out;
|
2003-04-09 22:15:05 +00:00
|
|
|
|
|
|
|
|
if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE)
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_loop_queue_dispatch (bus_context_get_loop (connections->context), connection))
|
|
|
|
|
{
|
|
|
|
|
bus_dispatch_remove_connection (connection);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
_dbus_list_append_link (&connections->incomplete, d->link_in_connection_list);
|
|
|
|
|
connections->n_incomplete += 1;
|
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
|
|
|
dbus_connection_ref (connection);
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
/* Note that we might disconnect ourselves here, but it only takes
|
2003-04-24 21:26:25 +00:00
|
|
|
* effect on return to the main loop. We call this to free up
|
|
|
|
|
* expired connections if possible, and to queue the timeout for our
|
|
|
|
|
* own expiration.
|
|
|
|
|
*/
|
|
|
|
|
bus_connections_expire_incomplete (connections);
|
|
|
|
|
|
|
|
|
|
/* And we might also disconnect ourselves here, but again it
|
|
|
|
|
* only takes effect on return to main loop.
|
2003-04-19 16:16:24 +00:00
|
|
|
*/
|
|
|
|
|
if (connections->n_incomplete >
|
|
|
|
|
bus_context_get_max_incomplete_connections (connections->context))
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Number of incomplete connections exceeds max, dropping oldest one\n");
|
|
|
|
|
|
|
|
|
|
_dbus_assert (connections->incomplete != NULL);
|
|
|
|
|
/* Disconnect the oldest unauthenticated connection. FIXME
|
|
|
|
|
* would it be more secure to drop a *random* connection? This
|
|
|
|
|
* algorithm seems to mean that if someone can create new
|
|
|
|
|
* connections quickly enough, they can keep anyone else from
|
|
|
|
|
* completing authentication. But random may or may not really
|
|
|
|
|
* help with that, a more elaborate solution might be required.
|
|
|
|
|
*/
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (connections->incomplete->data);
|
2003-04-19 16:16:24 +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
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
if (!retval)
|
2004-07-30 05:59:34 +00:00
|
|
|
{
|
|
|
|
|
if (d->selinux_id)
|
|
|
|
|
bus_selinux_id_unref (d->selinux_id);
|
|
|
|
|
d->selinux_id = 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
|
|
|
if (!dbus_connection_set_watch_functions (connection,
|
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
|
connection,
|
|
|
|
|
NULL))
|
|
|
|
|
_dbus_assert_not_reached ("setting watch functions to NULL failed");
|
|
|
|
|
|
|
|
|
|
if (!dbus_connection_set_timeout_functions (connection,
|
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
|
connection,
|
|
|
|
|
NULL))
|
|
|
|
|
_dbus_assert_not_reached ("setting timeout functions to NULL failed");
|
2003-03-24 17:30:47 +00:00
|
|
|
|
|
|
|
|
dbus_connection_set_unix_user_function (connection,
|
|
|
|
|
NULL, NULL, NULL);
|
2003-04-04 00:39:22 +00:00
|
|
|
|
2007-06-09 23:41:33 +00:00
|
|
|
dbus_connection_set_windows_user_function (connection,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
|
2003-04-09 22:15:05 +00:00
|
|
|
dbus_connection_set_dispatch_status_function (connection,
|
|
|
|
|
NULL, NULL, NULL);
|
2003-04-19 16:16:24 +00:00
|
|
|
|
|
|
|
|
if (d->link_in_connection_list != NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_assert (d->link_in_connection_list->next == NULL);
|
|
|
|
|
_dbus_assert (d->link_in_connection_list->prev == NULL);
|
|
|
|
|
_dbus_list_free_link (d->link_in_connection_list);
|
2003-05-12 02:44:45 +00:00
|
|
|
d->link_in_connection_list = NULL;
|
2003-04-19 16:16:24 +00:00
|
|
|
}
|
2003-05-12 02:44:45 +00:00
|
|
|
|
|
|
|
|
if (!dbus_connection_set_data (connection,
|
|
|
|
|
connection_data_slot,
|
|
|
|
|
NULL, NULL))
|
|
|
|
|
_dbus_assert_not_reached ("failed to set connection data to null");
|
|
|
|
|
|
|
|
|
|
/* "d" has now been freed */
|
2003-03-16 Havoc Pennington <hp@pobox.com>
Oops - test code was only testing failure of around 30 of the
mallocs in the test path, but it turns out there are 500+
mallocs. I believe this was due to misguided linking setup such
that there was one copy of dbus_malloc etc. in the daemon and one
in the shared lib, and only daemon mallocs were tested. In any
case, the test case now tests all 500+ mallocs, and doesn't pass
yet, though there are lots of fixes in this patch.
* dbus/dbus-connection.c (dbus_connection_dispatch_message): fix
this so that it doesn't need to allocate memory, since it
has no way of indicating failure due to OOM (and would be
annoying if it did).
* dbus/dbus-list.c (_dbus_list_pop_first_link): new function
* bus/Makefile.am: rearrange to create two self-contained
libraries, to avoid having libraries with overlapping symbols.
that was resulting in weirdness, e.g. I'm pretty sure there
were two copies of global static variables.
* dbus/dbus-internals.c: move the malloc debug stuff to
dbus-memory.c
* dbus/dbus-list.c (free_link): free list mempool if it becomes
empty.
* dbus/dbus-memory.c (_dbus_disable_mem_pools): new function
* dbus/dbus-address.c (dbus_parse_address): free list nodes
on failure.
* bus/dispatch.c (bus_dispatch_add_connection): free
message_handler_slot when no longer using it, so
memory leak checkers are happy for the test suite.
* dbus/dbus-server-debug-pipe.c (debug_finalize): free server name
* bus/bus.c (new_connection_callback): disconnect in here if
bus_connections_setup_connection fails.
* bus/connection.c (bus_connections_unref): fix to free the
connections
(bus_connections_setup_connection): if this fails, don't
disconnect the connection, just be sure there are no side
effects.
* dbus/dbus-string.c (undo_alignment): unbreak this
* dbus/dbus-auth.c (_dbus_auth_unref): free some stuff we were
leaking
(_dbus_auth_new): fix the order in which we free strings
on OOM failure
* bus/connection.c (bus_connection_disconnected): fix to
not send ServiceDeleted multiple times in case of memory
allocation failure
* dbus/dbus-bus.c (dbus_bus_get_base_service): new function to
get the base service name
(dbus_bus_register_client): don't return base service name,
instead store it on the DBusConnection and have an accessor
function for it.
(dbus_bus_register_client): rename dbus_bus_register()
* bus/dispatch.c (check_hello_message): verify that other
connections on the bus also got the correct results, not
just the one sending hello
2003-03-16 08:08:21 +00:00
|
|
|
}
|
2003-01-21 12:42:33 +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
|
|
|
return retval;
|
2003-01-06 01:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
void
|
|
|
|
|
bus_connections_expire_incomplete (BusConnections *connections)
|
|
|
|
|
{
|
|
|
|
|
int next_interval;
|
|
|
|
|
|
|
|
|
|
next_interval = -1;
|
|
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
if (connections->incomplete != NULL)
|
2003-04-24 21:26:25 +00:00
|
|
|
{
|
2003-04-25 23:50:34 +00:00
|
|
|
long tv_sec, tv_usec;
|
|
|
|
|
DBusList *link;
|
|
|
|
|
int auth_timeout;
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
_dbus_get_current_time (&tv_sec, &tv_usec);
|
|
|
|
|
auth_timeout = bus_context_get_auth_timeout (connections->context);
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_get_first_link (&connections->incomplete);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link);
|
|
|
|
|
DBusConnection *connection;
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
double elapsed;
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
connection = link->data;
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
2003-10-11 06:20:28 +00:00
|
|
|
elapsed = ELAPSED_MILLISECONDS_SINCE (d->connection_tv_sec,
|
|
|
|
|
d->connection_tv_usec,
|
|
|
|
|
tv_sec, tv_usec);
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
if (elapsed >= (double) auth_timeout)
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Timing out authentication for connection %p\n", connection);
|
2005-06-02 17:41:04 +00:00
|
|
|
dbus_connection_close (connection);
|
2003-04-25 23:50:34 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We can end the loop, since the connections are in oldest-first order */
|
|
|
|
|
next_interval = ((double)auth_timeout) - elapsed;
|
|
|
|
|
_dbus_verbose ("Connection %p authentication expires in %d milliseconds\n",
|
|
|
|
|
connection, next_interval);
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
link = next;
|
|
|
|
|
}
|
2003-04-24 21:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-11 06:20:28 +00:00
|
|
|
bus_expire_timeout_set_interval (connections->expire_timeout,
|
|
|
|
|
next_interval);
|
2003-04-24 21:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
expire_incomplete_timeout (void *data)
|
|
|
|
|
{
|
|
|
|
|
BusConnections *connections = data;
|
|
|
|
|
|
2003-04-25 23:50:34 +00:00
|
|
|
_dbus_verbose ("Running %s\n", _DBUS_FUNCTION_NAME);
|
|
|
|
|
|
2003-04-24 21:26:25 +00:00
|
|
|
/* note that this may remove the timeout */
|
|
|
|
|
bus_connections_expire_incomplete (connections);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-23 07:41:54 +00:00
|
|
|
dbus_bool_t
|
2007-06-09 23:41:33 +00:00
|
|
|
bus_connection_get_unix_groups (DBusConnection *connection,
|
|
|
|
|
unsigned long **groups,
|
|
|
|
|
int *n_groups,
|
|
|
|
|
DBusError *error)
|
2003-03-23 07:41:54 +00:00
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
2003-04-17 00:46:36 +00:00
|
|
|
unsigned long uid;
|
|
|
|
|
|
2003-03-23 07:41:54 +00:00
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
*groups = NULL;
|
|
|
|
|
*n_groups = 0;
|
|
|
|
|
|
2003-04-17 00:46:36 +00:00
|
|
|
if (dbus_connection_get_unix_user (connection, &uid))
|
2003-03-23 07:41:54 +00:00
|
|
|
{
|
2007-06-09 23:41:33 +00:00
|
|
|
if (!_dbus_unix_groups_from_uid (uid, groups, n_groups))
|
2003-03-23 07:41:54 +00:00
|
|
|
{
|
2003-04-17 00:46:36 +00:00
|
|
|
_dbus_verbose ("Did not get any groups for UID %lu\n",
|
|
|
|
|
uid);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Got %d groups for UID %lu\n",
|
|
|
|
|
*n_groups, uid);
|
|
|
|
|
return TRUE;
|
2003-03-23 07:41:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-04-17 00:46:36 +00:00
|
|
|
else
|
|
|
|
|
return TRUE; /* successfully got 0 groups */
|
2003-03-23 07:41:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
2007-06-09 23:41:33 +00:00
|
|
|
bus_connection_is_in_unix_group (DBusConnection *connection,
|
|
|
|
|
unsigned long gid)
|
2003-03-23 07:41:54 +00:00
|
|
|
{
|
|
|
|
|
int i;
|
2003-04-17 00:46:36 +00:00
|
|
|
unsigned long *group_ids;
|
2003-03-23 07:41:54 +00:00
|
|
|
int n_group_ids;
|
|
|
|
|
|
2007-06-09 23:41:33 +00:00
|
|
|
if (!bus_connection_get_unix_groups (connection, &group_ids, &n_group_ids,
|
|
|
|
|
NULL))
|
2003-03-23 07:41:54 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
while (i < n_group_ids)
|
|
|
|
|
{
|
|
|
|
|
if (group_ids[i] == gid)
|
2003-04-17 00:46:36 +00:00
|
|
|
{
|
|
|
|
|
dbus_free (group_ids);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-03-23 07:41:54 +00:00
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-17 00:46:36 +00:00
|
|
|
dbus_free (group_ids);
|
2003-03-23 07:41:54 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-17 16:01:28 -05:00
|
|
|
const char *
|
|
|
|
|
bus_connection_get_loginfo (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
if (!bus_connection_is_active (connection))
|
|
|
|
|
return "inactive";
|
|
|
|
|
return d->cached_loginfo_string;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-12 18:32:11 +00:00
|
|
|
BusClientPolicy*
|
2003-04-27 06:25:42 +00:00
|
|
|
bus_connection_get_policy (DBusConnection *connection)
|
2003-03-23 07:41:54 +00:00
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
2003-04-27 06:25:42 +00:00
|
|
|
_dbus_assert (d->policy != NULL);
|
2003-04-25 23:50:34 +00:00
|
|
|
|
2003-03-23 07:41:54 +00:00
|
|
|
return d->policy;
|
|
|
|
|
}
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
foreach_active (BusConnections *connections,
|
|
|
|
|
BusConnectionForeachFunction function,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_get_first_link (&connections->completed);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection = link->data;
|
|
|
|
|
DBusList *next = _dbus_list_get_next_link (&connections->completed, link);
|
|
|
|
|
|
|
|
|
|
if (!(* function) (connection, data))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
link = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static dbus_bool_t
|
|
|
|
|
foreach_inactive (BusConnections *connections,
|
|
|
|
|
BusConnectionForeachFunction function,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_get_first_link (&connections->incomplete);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBusConnection *connection = link->data;
|
|
|
|
|
DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link);
|
|
|
|
|
|
|
|
|
|
if (!(* function) (connection, data))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
link = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Calls function on each active connection; if the function returns
|
|
|
|
|
* #FALSE, stops iterating. Active connections are authenticated
|
|
|
|
|
* and have sent a Hello message.
|
|
|
|
|
*
|
|
|
|
|
* @param connections the connections object
|
|
|
|
|
* @param function the function
|
|
|
|
|
* @param data data to pass to it as a second arg
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
bus_connections_foreach_active (BusConnections *connections,
|
|
|
|
|
BusConnectionForeachFunction function,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
foreach_active (connections, function, data);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
/**
|
|
|
|
|
* Calls function on each connection; if the function returns
|
|
|
|
|
* #FALSE, stops iterating.
|
|
|
|
|
*
|
|
|
|
|
* @param connections the connections object
|
|
|
|
|
* @param function the function
|
|
|
|
|
* @param data data to pass to it as a second arg
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
bus_connections_foreach (BusConnections *connections,
|
|
|
|
|
BusConnectionForeachFunction function,
|
2003-04-19 16:16:24 +00:00
|
|
|
void *data)
|
2003-03-13 03:52:58 +00:00
|
|
|
{
|
2003-04-19 16:16:24 +00:00
|
|
|
if (!foreach_active (connections, function, data))
|
|
|
|
|
return;
|
2003-03-13 03:52:58 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
foreach_inactive (connections, function, data);
|
2003-03-13 03:52:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BusContext*
|
|
|
|
|
bus_connections_get_context (BusConnections *connections)
|
|
|
|
|
{
|
|
|
|
|
return connections->context;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
/*
|
|
|
|
|
* This is used to avoid covering the same connection twice when
|
|
|
|
|
* traversing connections. Note that it assumes we will
|
|
|
|
|
* bus_connection_mark_stamp() each connection at least once per
|
|
|
|
|
* INT_MAX increments of the global stamp, or wraparound would break
|
|
|
|
|
* things.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
bus_connections_increment_stamp (BusConnections *connections)
|
|
|
|
|
{
|
|
|
|
|
connections->stamp += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mark connection with current stamp, return TRUE if it
|
|
|
|
|
* didn't already have that stamp
|
|
|
|
|
*/
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connection_mark_stamp (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
if (d->stamp == d->connections->stamp)
|
|
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
d->stamp = d->connections->stamp;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
BusContext*
|
|
|
|
|
bus_connection_get_context (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return d->connections->context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BusConnections*
|
|
|
|
|
bus_connection_get_connections (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return d->connections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BusRegistry*
|
|
|
|
|
bus_connection_get_registry (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return bus_context_get_registry (d->connections->context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BusActivation*
|
|
|
|
|
bus_connection_get_activation (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return bus_context_get_activation (d->connections->context);
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
BusMatchmaker*
|
|
|
|
|
bus_connection_get_matchmaker (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return bus_context_get_matchmaker (d->connections->context);
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-30 05:59:34 +00:00
|
|
|
BusSELinuxID*
|
|
|
|
|
bus_connection_get_selinux_id (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return d->selinux_id;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/**
|
|
|
|
|
* Checks whether the connection is registered with the message bus.
|
|
|
|
|
*
|
|
|
|
|
* @param connection the connection
|
|
|
|
|
* @returns #TRUE if we're an active message bus participant
|
|
|
|
|
*/
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connection_is_active (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
return d != NULL && d->name != NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connection_preallocate_oom_error (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusPreallocatedSend *preallocated;
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
if (d->oom_preallocated != NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
preallocated = dbus_connection_preallocate_send (connection);
|
|
|
|
|
if (preallocated == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
dbus_connection_free_preallocated_send (connection, preallocated);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
/* d->name may be NULL, but that is OK */
|
2003-08-18 15:27:33 +00:00
|
|
|
if (!dbus_message_set_error_name (message, DBUS_ERROR_NO_MEMORY) ||
|
2003-08-11 02:11:58 +00:00
|
|
|
!dbus_message_set_destination (message, d->name) ||
|
|
|
|
|
!dbus_message_set_sender (message,
|
2005-02-17 21:19:49 +00:00
|
|
|
DBUS_SERVICE_DBUS))
|
2003-03-20 07:57:39 +00:00
|
|
|
{
|
|
|
|
|
dbus_connection_free_preallocated_send (connection, preallocated);
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-03-15 20:47:16 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
/* set reply serial to placeholder value just so space is already allocated
|
|
|
|
|
* for it.
|
|
|
|
|
*/
|
|
|
|
|
if (!dbus_message_set_reply_serial (message, 14))
|
|
|
|
|
{
|
|
|
|
|
dbus_connection_free_preallocated_send (connection, preallocated);
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d->oom_message = message;
|
|
|
|
|
d->oom_preallocated = preallocated;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_connection_send_oom_error (DBusConnection *connection,
|
|
|
|
|
DBusMessage *in_reply_to)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
_dbus_assert (d->oom_message != NULL);
|
|
|
|
|
|
|
|
|
|
/* should always succeed since we set it to a placeholder earlier */
|
|
|
|
|
if (!dbus_message_set_reply_serial (d->oom_message,
|
|
|
|
|
dbus_message_get_serial (in_reply_to)))
|
|
|
|
|
_dbus_assert_not_reached ("Failed to set reply serial for preallocated oom message");
|
|
|
|
|
|
2003-03-20 07:57:39 +00:00
|
|
|
_dbus_assert (dbus_message_get_sender (d->oom_message) != NULL);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_connection_send_preallocated (connection, d->oom_preallocated,
|
|
|
|
|
d->oom_message, NULL);
|
|
|
|
|
|
|
|
|
|
dbus_message_unref (d->oom_message);
|
|
|
|
|
d->oom_message = NULL;
|
|
|
|
|
d->oom_preallocated = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-21 19:53:56 +00:00
|
|
|
void
|
|
|
|
|
bus_connection_add_match_rule_link (DBusConnection *connection,
|
|
|
|
|
DBusList *link)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_list_append_link (&d->match_rules, link);
|
|
|
|
|
|
|
|
|
|
d->n_match_rules += 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connection_add_match_rule (DBusConnection *connection,
|
|
|
|
|
BusMatchRule *rule)
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_alloc_link (rule);
|
|
|
|
|
|
|
|
|
|
if (link == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
bus_connection_add_match_rule_link (connection, link);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_connection_remove_match_rule (DBusConnection *connection,
|
|
|
|
|
BusMatchRule *rule)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_list_remove_last (&d->match_rules, rule);
|
|
|
|
|
|
|
|
|
|
d->n_match_rules -= 1;
|
|
|
|
|
_dbus_assert (d->n_match_rules >= 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
bus_connection_get_n_match_rules (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return d->n_match_rules;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
void
|
|
|
|
|
bus_connection_add_owned_service_link (DBusConnection *connection,
|
|
|
|
|
DBusList *link)
|
2003-01-06 01:08:14 +00:00
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
_dbus_list_append_link (&d->services_owned, link);
|
2003-04-25 23:50:34 +00:00
|
|
|
|
|
|
|
|
d->n_services_owned += 1;
|
2003-04-11 00:03:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connection_add_owned_service (DBusConnection *connection,
|
|
|
|
|
BusService *service)
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_alloc_link (service);
|
|
|
|
|
|
|
|
|
|
if (link == NULL)
|
2003-01-06 01:08:14 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
bus_connection_add_owned_service_link (connection, link);
|
|
|
|
|
|
2003-01-06 01:08:14 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_connection_remove_owned_service (DBusConnection *connection,
|
|
|
|
|
BusService *service)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_list_remove_last (&d->services_owned, service);
|
2003-04-25 23:50:34 +00:00
|
|
|
|
|
|
|
|
d->n_services_owned -= 1;
|
|
|
|
|
_dbus_assert (d->n_services_owned >= 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
bus_connection_get_n_services_owned (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return d->n_services_owned;
|
2003-01-06 01:08:14 +00:00
|
|
|
}
|
2003-01-21 12:42:33 +00:00
|
|
|
|
|
|
|
|
dbus_bool_t
|
2003-04-27 06:25:42 +00:00
|
|
|
bus_connection_complete (DBusConnection *connection,
|
|
|
|
|
const DBusString *name,
|
|
|
|
|
DBusError *error)
|
2003-01-21 12:42:33 +00:00
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
2003-04-19 16:16:24 +00:00
|
|
|
unsigned long uid;
|
2003-01-21 12:42:33 +00:00
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
_dbus_assert (d->name == NULL);
|
2003-04-27 06:25:42 +00:00
|
|
|
_dbus_assert (d->policy == NULL);
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!bus_connection_is_active (connection));
|
2003-04-19 16:16:24 +00:00
|
|
|
|
2003-03-31 20:56:29 +00:00
|
|
|
if (!_dbus_string_copy_data (name, &d->name))
|
2003-04-27 06:25:42 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-01-21 12:42:33 +00:00
|
|
|
|
2003-03-31 20:56:29 +00:00
|
|
|
_dbus_assert (d->name != NULL);
|
|
|
|
|
|
2003-03-16 21:01:57 +00:00
|
|
|
_dbus_verbose ("Name %s assigned to %p\n", d->name, connection);
|
2003-04-19 16:16:24 +00:00
|
|
|
|
2003-04-27 06:25:42 +00:00
|
|
|
d->policy = bus_context_create_client_policy (d->connections->context,
|
|
|
|
|
connection,
|
|
|
|
|
error);
|
|
|
|
|
|
|
|
|
|
/* we may have a NULL policy on OOM or error getting list of
|
|
|
|
|
* groups for a user. In the latter case we don't handle it so
|
|
|
|
|
* well currently, as it will just keep failing over and over.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (d->policy == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Failed to create security policy for connection %p\n",
|
|
|
|
|
connection);
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
|
|
|
|
dbus_free (d->name);
|
|
|
|
|
d->name = NULL;
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
if (dbus_connection_get_unix_user (connection, &uid))
|
|
|
|
|
{
|
|
|
|
|
if (!adjust_connections_for_uid (d->connections,
|
|
|
|
|
uid, 1))
|
2008-12-17 16:01:28 -05:00
|
|
|
goto fail;
|
2003-04-19 16:16:24 +00:00
|
|
|
}
|
2008-12-17 16:01:28 -05:00
|
|
|
|
|
|
|
|
/* Create and cache a string which holds information about the
|
|
|
|
|
* peer process; used for logging purposes.
|
|
|
|
|
*/
|
|
|
|
|
if (!cache_peer_loginfo_string (d, connection))
|
|
|
|
|
goto fail;
|
|
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
/* Now the connection is active, move it between lists */
|
|
|
|
|
_dbus_list_unlink (&d->connections->incomplete,
|
|
|
|
|
d->link_in_connection_list);
|
|
|
|
|
d->connections->n_incomplete -= 1;
|
|
|
|
|
_dbus_list_append_link (&d->connections->completed,
|
|
|
|
|
d->link_in_connection_list);
|
|
|
|
|
d->connections->n_completed += 1;
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d->connections->n_incomplete >= 0);
|
|
|
|
|
_dbus_assert (d->connections->n_completed > 0);
|
2003-04-25 23:50:34 +00:00
|
|
|
|
|
|
|
|
/* See if we can remove the timeout */
|
|
|
|
|
bus_connections_expire_incomplete (d->connections);
|
2003-09-21 19:53:56 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (bus_connection_is_active (connection));
|
2003-03-16 21:01:57 +00:00
|
|
|
|
2003-01-21 12:42:33 +00:00
|
|
|
return TRUE;
|
2008-12-17 16:01:28 -05:00
|
|
|
fail:
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
dbus_free (d->name);
|
|
|
|
|
d->name = NULL;
|
|
|
|
|
if (d->policy)
|
|
|
|
|
bus_client_policy_unref (d->policy);
|
|
|
|
|
d->policy = NULL;
|
|
|
|
|
return FALSE;
|
2003-01-21 12:42:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
bus_connection_get_name (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
return d->name;
|
|
|
|
|
}
|
2003-01-24 23:51:59 +00:00
|
|
|
|
2003-04-19 16:16:24 +00:00
|
|
|
/**
|
|
|
|
|
* Check whether completing the passed-in connection would
|
|
|
|
|
* exceed limits, and if so set error and return #FALSE
|
|
|
|
|
*/
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connections_check_limits (BusConnections *connections,
|
|
|
|
|
DBusConnection *requesting_completion,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
unsigned long uid;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (requesting_completion);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (d->name == NULL);
|
|
|
|
|
|
|
|
|
|
if (connections->n_completed >=
|
|
|
|
|
bus_context_get_max_completed_connections (connections->context))
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
|
|
|
|
|
"The maximum number of active connections has been reached");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dbus_connection_get_unix_user (requesting_completion, &uid))
|
|
|
|
|
{
|
|
|
|
|
if (get_connections_for_uid (connections, uid) >=
|
|
|
|
|
bus_context_get_max_connections_per_user (connections->context))
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
|
|
|
|
|
"The maximum number of active connections for UID %lu has been reached",
|
|
|
|
|
uid);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
static void
|
|
|
|
|
bus_pending_reply_free (BusPendingReply *pending)
|
|
|
|
|
{
|
|
|
|
|
_dbus_verbose ("Freeing pending reply %p, replier %p receiver %p serial %u\n",
|
|
|
|
|
pending,
|
|
|
|
|
pending->will_send_reply,
|
|
|
|
|
pending->will_get_reply,
|
|
|
|
|
pending->reply_serial);
|
|
|
|
|
|
|
|
|
|
dbus_free (pending);
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
static dbus_bool_t
|
|
|
|
|
bus_pending_reply_send_no_reply (BusConnections *connections,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
BusPendingReply *pending)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusMessageIter iter;
|
|
|
|
|
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 *errmsg;
|
2003-10-14 05:16:56 +00:00
|
|
|
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
|
|
|
|
|
message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
|
|
|
|
|
if (message == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
dbus_message_set_no_reply (message, TRUE);
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_set_reply_serial (message,
|
|
|
|
|
pending->reply_serial))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (!dbus_message_set_error_name (message,
|
|
|
|
|
DBUS_ERROR_NO_REPLY))
|
|
|
|
|
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
|
|
|
|
|
|
|
|
errmsg = "Message did not receive a reply (timeout by message bus)";
|
2005-01-16 15:51:55 +00:00
|
|
|
dbus_message_iter_init_append (message, &iter);
|
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_iter_append_basic (&iter, DBUS_TYPE_STRING, &errmsg))
|
2003-10-14 05:16:56 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
if (!bus_transaction_send_from_driver (transaction, pending->will_get_reply,
|
|
|
|
|
message))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
dbus_message_unref (message);
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-28 23:51:24 +00:00
|
|
|
static dbus_bool_t
|
2003-10-14 05:16:56 +00:00
|
|
|
bus_pending_reply_expired (BusExpireList *list,
|
|
|
|
|
DBusList *link,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
BusPendingReply *pending = link->data;
|
|
|
|
|
BusConnections *connections = data;
|
|
|
|
|
BusTransaction *transaction;
|
|
|
|
|
|
|
|
|
|
/* No reply is forthcoming. So nuke it if we can. If not,
|
|
|
|
|
* leave it in the list to try expiring again later when we
|
|
|
|
|
* get more memory.
|
|
|
|
|
*/
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("Expiring pending reply %p, replier %p receiver %p serial %u\n",
|
|
|
|
|
pending,
|
|
|
|
|
pending->will_send_reply,
|
|
|
|
|
pending->will_get_reply,
|
|
|
|
|
pending->reply_serial);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
transaction = bus_transaction_new (connections->context);
|
|
|
|
|
if (transaction == NULL)
|
2003-10-28 23:51:24 +00:00
|
|
|
return FALSE;
|
2003-10-14 05:16:56 +00:00
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
if (!bus_pending_reply_send_no_reply (connections,
|
|
|
|
|
transaction,
|
|
|
|
|
pending))
|
2003-10-14 05:16:56 +00:00
|
|
|
{
|
|
|
|
|
bus_transaction_cancel_and_free (transaction);
|
2003-10-28 23:51:24 +00:00
|
|
|
return FALSE;
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
2007-11-08 17:51:15 -05:00
|
|
|
|
|
|
|
|
bus_expire_list_remove_link (connections->pending_replies, link);
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
bus_pending_reply_free (pending);
|
2003-10-14 05:16:56 +00:00
|
|
|
bus_transaction_execute_and_free (transaction);
|
2003-10-28 23:51:24 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bus_connection_drop_pending_replies (BusConnections *connections,
|
|
|
|
|
DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
/* The DBusConnection is almost 100% finalized here, so you can't
|
|
|
|
|
* do anything with it except check for pointer equality
|
|
|
|
|
*/
|
|
|
|
|
DBusList *link;
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("Dropping pending replies that involve connection %p\n",
|
|
|
|
|
connection);
|
2003-10-14 05:16:56 +00:00
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
link = bus_expire_list_get_first_link (connections->pending_replies);
|
2003-10-14 05:16:56 +00:00
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
DBusList *next;
|
|
|
|
|
BusPendingReply *pending;
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
next = bus_expire_list_get_next_link (connections->pending_replies,
|
|
|
|
|
link);
|
2003-10-14 05:16:56 +00:00
|
|
|
pending = link->data;
|
|
|
|
|
|
|
|
|
|
if (pending->will_get_reply == connection)
|
|
|
|
|
{
|
|
|
|
|
/* We don't need to track this pending reply anymore */
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("Dropping pending reply %p, replier %p receiver %p serial %u\n",
|
|
|
|
|
pending,
|
|
|
|
|
pending->will_send_reply,
|
|
|
|
|
pending->will_get_reply,
|
|
|
|
|
pending->reply_serial);
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
bus_expire_list_remove_link (connections->pending_replies,
|
|
|
|
|
link);
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
bus_pending_reply_free (pending);
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
|
|
|
|
else if (pending->will_send_reply == connection)
|
|
|
|
|
{
|
|
|
|
|
/* The reply isn't going to be sent, so set things
|
|
|
|
|
* up so it will be expired right away
|
|
|
|
|
*/
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("Will expire pending reply %p, replier %p receiver %p serial %u\n",
|
|
|
|
|
pending,
|
|
|
|
|
pending->will_send_reply,
|
|
|
|
|
pending->will_get_reply,
|
|
|
|
|
pending->reply_serial);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
pending->will_send_reply = NULL;
|
|
|
|
|
pending->expire_item.added_tv_sec = 0;
|
|
|
|
|
pending->expire_item.added_tv_usec = 0;
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
bus_expire_list_recheck_immediately (connections->pending_replies);
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
link = next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
BusPendingReply *pending;
|
|
|
|
|
BusConnections *connections;
|
|
|
|
|
} CancelPendingReplyData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cancel_pending_reply (void *data)
|
|
|
|
|
{
|
|
|
|
|
CancelPendingReplyData *d = data;
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
if (!bus_expire_list_remove (d->connections->pending_replies,
|
|
|
|
|
&d->pending->expire_item))
|
2003-10-14 05:16:56 +00:00
|
|
|
_dbus_assert_not_reached ("pending reply did not exist to be cancelled");
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
bus_pending_reply_free (d->pending); /* since it's been cancelled */
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cancel_pending_reply_data_free (void *data)
|
|
|
|
|
{
|
|
|
|
|
CancelPendingReplyData *d = data;
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
/* d->pending should be either freed or still
|
|
|
|
|
* in the list of pending replies (owned by someone
|
|
|
|
|
* else)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
dbus_free (d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Record that a reply is allowed; return TRUE on success.
|
|
|
|
|
*/
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connections_expect_reply (BusConnections *connections,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusConnection *will_get_reply,
|
|
|
|
|
DBusConnection *will_send_reply,
|
|
|
|
|
DBusMessage *reply_to_this,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
BusPendingReply *pending;
|
|
|
|
|
dbus_uint32_t reply_serial;
|
|
|
|
|
DBusList *link;
|
|
|
|
|
CancelPendingReplyData *cprd;
|
2004-05-20 19:47:36 +00:00
|
|
|
int count;
|
2003-10-14 05:16:56 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (will_get_reply != NULL);
|
|
|
|
|
_dbus_assert (will_send_reply != NULL);
|
|
|
|
|
_dbus_assert (reply_to_this != NULL);
|
|
|
|
|
|
|
|
|
|
if (dbus_message_get_no_reply (reply_to_this))
|
|
|
|
|
return TRUE; /* we won't allow a reply, since client doesn't care for one. */
|
|
|
|
|
|
2003-10-14 22:16:03 +00:00
|
|
|
reply_serial = dbus_message_get_serial (reply_to_this);
|
2003-10-14 05:16:56 +00:00
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
link = bus_expire_list_get_first_link (connections->pending_replies);
|
2004-05-20 19:47:36 +00:00
|
|
|
count = 0;
|
2003-10-14 05:16:56 +00:00
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
pending = link->data;
|
|
|
|
|
|
|
|
|
|
if (pending->reply_serial == reply_serial &&
|
|
|
|
|
pending->will_get_reply == will_get_reply &&
|
|
|
|
|
pending->will_send_reply == will_send_reply)
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
|
|
|
|
|
"Message has the same reply serial as a currently-outstanding existing method call");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
link = bus_expire_list_get_next_link (connections->pending_replies,
|
|
|
|
|
link);
|
2006-02-10 21:44:15 +00:00
|
|
|
if (pending->will_get_reply == will_get_reply)
|
|
|
|
|
++count;
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
2004-05-20 19:47:36 +00:00
|
|
|
if (count >=
|
|
|
|
|
bus_context_get_max_replies_per_connection (connections->context))
|
|
|
|
|
{
|
|
|
|
|
dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
|
|
|
|
|
"The maximum number of pending replies per connection has been reached");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
pending = dbus_new0 (BusPendingReply, 1);
|
|
|
|
|
if (pending == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
#ifdef DBUS_ENABLE_VERBOSE_MODE
|
|
|
|
|
/* so we can see a not-yet-added pending reply */
|
|
|
|
|
pending->expire_item.added_tv_sec = 1;
|
|
|
|
|
pending->expire_item.added_tv_usec = 1;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
pending->will_get_reply = will_get_reply;
|
|
|
|
|
pending->will_send_reply = will_send_reply;
|
|
|
|
|
pending->reply_serial = reply_serial;
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
cprd = dbus_new0 (CancelPendingReplyData, 1);
|
|
|
|
|
if (cprd == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
bus_pending_reply_free (pending);
|
2003-10-14 05:16:56 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
if (!bus_expire_list_add (connections->pending_replies,
|
|
|
|
|
&pending->expire_item))
|
2003-10-14 05:16:56 +00:00
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
dbus_free (cprd);
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
bus_pending_reply_free (pending);
|
2003-10-14 05:16:56 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bus_transaction_add_cancel_hook (transaction,
|
|
|
|
|
cancel_pending_reply,
|
|
|
|
|
cprd,
|
|
|
|
|
cancel_pending_reply_data_free))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
2007-11-08 17:51:15 -05:00
|
|
|
bus_expire_list_remove (connections->pending_replies, &pending->expire_item);
|
2003-10-14 05:16:56 +00:00
|
|
|
dbus_free (cprd);
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
bus_pending_reply_free (pending);
|
2003-10-14 05:16:56 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cprd->pending = pending;
|
|
|
|
|
cprd->connections = connections;
|
|
|
|
|
|
|
|
|
|
_dbus_get_current_time (&pending->expire_item.added_tv_sec,
|
|
|
|
|
&pending->expire_item.added_tv_usec);
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("Added pending reply %p, replier %p receiver %p serial %u\n",
|
|
|
|
|
pending,
|
|
|
|
|
pending->will_send_reply,
|
|
|
|
|
pending->will_get_reply,
|
|
|
|
|
pending->reply_serial);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
BusConnections *connections;
|
|
|
|
|
} CheckPendingReplyData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cancel_check_pending_reply (void *data)
|
|
|
|
|
{
|
|
|
|
|
CheckPendingReplyData *d = data;
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
|
2007-11-08 17:51:15 -05:00
|
|
|
|
|
|
|
|
bus_expire_list_add_link (d->connections->pending_replies,
|
|
|
|
|
d->link);
|
2003-10-14 05:16:56 +00:00
|
|
|
d->link = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check_pending_reply_data_free (void *data)
|
|
|
|
|
{
|
|
|
|
|
CheckPendingReplyData *d = data;
|
|
|
|
|
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
if (d->link != NULL)
|
|
|
|
|
{
|
|
|
|
|
BusPendingReply *pending = d->link->data;
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
_dbus_assert (!bus_expire_list_contains_item (d->connections->pending_replies,
|
|
|
|
|
&pending->expire_item));
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
|
|
|
|
bus_pending_reply_free (pending);
|
2003-10-14 05:16:56 +00:00
|
|
|
_dbus_list_free_link (d->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_free (d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check whether a reply is allowed, remove BusPendingReply
|
|
|
|
|
* if so, return TRUE if so.
|
|
|
|
|
*/
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_connections_check_reply (BusConnections *connections,
|
|
|
|
|
BusTransaction *transaction,
|
|
|
|
|
DBusConnection *sending_reply,
|
|
|
|
|
DBusConnection *receiving_reply,
|
|
|
|
|
DBusMessage *reply,
|
|
|
|
|
DBusError *error)
|
|
|
|
|
{
|
|
|
|
|
CheckPendingReplyData *cprd;
|
|
|
|
|
DBusList *link;
|
|
|
|
|
dbus_uint32_t reply_serial;
|
|
|
|
|
|
|
|
|
|
_dbus_assert (sending_reply != NULL);
|
|
|
|
|
_dbus_assert (receiving_reply != NULL);
|
|
|
|
|
|
|
|
|
|
reply_serial = dbus_message_get_reply_serial (reply);
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
link = bus_expire_list_get_first_link (connections->pending_replies);
|
2003-10-14 05:16:56 +00:00
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
BusPendingReply *pending = link->data;
|
|
|
|
|
|
|
|
|
|
if (pending->reply_serial == reply_serial &&
|
|
|
|
|
pending->will_get_reply == receiving_reply &&
|
|
|
|
|
pending->will_send_reply == sending_reply)
|
|
|
|
|
{
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
_dbus_verbose ("Found pending reply with serial %u\n", reply_serial);
|
2003-10-14 05:16:56 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
link = bus_expire_list_get_next_link (connections->pending_replies,
|
|
|
|
|
link);
|
2003-10-14 05:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (link == NULL)
|
|
|
|
|
{
|
2003-10-14 22:16:03 +00:00
|
|
|
_dbus_verbose ("No pending reply expected\n");
|
|
|
|
|
|
2003-10-14 05:16:56 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cprd = dbus_new0 (CheckPendingReplyData, 1);
|
|
|
|
|
if (cprd == NULL)
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!bus_transaction_add_cancel_hook (transaction,
|
|
|
|
|
cancel_check_pending_reply,
|
|
|
|
|
cprd,
|
|
|
|
|
check_pending_reply_data_free))
|
|
|
|
|
{
|
|
|
|
|
BUS_SET_OOM (error);
|
|
|
|
|
dbus_free (cprd);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cprd->link = link;
|
|
|
|
|
cprd->connections = connections;
|
|
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
bus_expire_list_unlink (connections->pending_replies,
|
|
|
|
|
link);
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
2007-11-08 17:51:15 -05:00
|
|
|
_dbus_assert (!bus_expire_list_contains_item (connections->pending_replies, link->data));
|
2003-10-14 05:16:56 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-04-19 16:16:24 +00:00
|
|
|
|
2003-04-18 04:18:57 +00:00
|
|
|
/*
|
2003-04-11 00:03:06 +00:00
|
|
|
* Transactions
|
|
|
|
|
*
|
|
|
|
|
* Note that this is fairly fragile; in particular, don't try to use
|
|
|
|
|
* one transaction across any main loop iterations.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
BusTransaction *transaction;
|
|
|
|
|
DBusMessage *message;
|
|
|
|
|
DBusPreallocatedSend *preallocated;
|
|
|
|
|
} MessageToSend;
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
BusTransactionCancelFunction cancel_function;
|
|
|
|
|
DBusFreeFunction free_data_function;
|
|
|
|
|
void *data;
|
|
|
|
|
} CancelHook;
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
struct BusTransaction
|
|
|
|
|
{
|
|
|
|
|
DBusList *connections;
|
2003-03-13 03:52:58 +00:00
|
|
|
BusContext *context;
|
2003-04-11 00:03:06 +00:00
|
|
|
DBusList *cancel_hooks;
|
2003-03-13 00:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
message_to_send_free (DBusConnection *connection,
|
|
|
|
|
MessageToSend *to_send)
|
|
|
|
|
{
|
|
|
|
|
if (to_send->message)
|
|
|
|
|
dbus_message_unref (to_send->message);
|
|
|
|
|
|
|
|
|
|
if (to_send->preallocated)
|
|
|
|
|
dbus_connection_free_preallocated_send (connection, to_send->preallocated);
|
|
|
|
|
|
|
|
|
|
dbus_free (to_send);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
static void
|
|
|
|
|
cancel_hook_cancel (void *element,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
CancelHook *ch = element;
|
|
|
|
|
|
|
|
|
|
_dbus_verbose ("Running transaction cancel hook\n");
|
|
|
|
|
|
|
|
|
|
if (ch->cancel_function)
|
|
|
|
|
(* ch->cancel_function) (ch->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cancel_hook_free (void *element,
|
|
|
|
|
void *data)
|
|
|
|
|
{
|
|
|
|
|
CancelHook *ch = element;
|
|
|
|
|
|
|
|
|
|
if (ch->free_data_function)
|
|
|
|
|
(* ch->free_data_function) (ch->data);
|
|
|
|
|
|
|
|
|
|
dbus_free (ch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
free_cancel_hooks (BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
_dbus_list_foreach (&transaction->cancel_hooks,
|
|
|
|
|
cancel_hook_free, NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_list_clear (&transaction->cancel_hooks);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
BusTransaction*
|
2003-03-13 03:52:58 +00:00
|
|
|
bus_transaction_new (BusContext *context)
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
BusTransaction *transaction;
|
|
|
|
|
|
|
|
|
|
transaction = dbus_new0 (BusTransaction, 1);
|
|
|
|
|
if (transaction == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
transaction->context = context;
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
return transaction;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 03:52:58 +00:00
|
|
|
BusContext*
|
|
|
|
|
bus_transaction_get_context (BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
return transaction->context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BusConnections*
|
|
|
|
|
bus_transaction_get_connections (BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
return bus_context_get_connections (transaction->context);
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_bool_t
|
2003-04-14 02:29:21 +00:00
|
|
|
bus_transaction_send_from_driver (BusTransaction *transaction,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
DBusMessage *message)
|
|
|
|
|
{
|
|
|
|
|
/* We have to set the sender to the driver, and have
|
|
|
|
|
* to check security policy since it was not done in
|
|
|
|
|
* dispatch.c
|
|
|
|
|
*/
|
2003-08-18 15:27:33 +00:00
|
|
|
_dbus_verbose ("Sending %s %s %s from driver\n",
|
|
|
|
|
dbus_message_get_interface (message) ?
|
|
|
|
|
dbus_message_get_interface (message) : "(no interface)",
|
|
|
|
|
dbus_message_get_member (message) ?
|
|
|
|
|
dbus_message_get_member (message) : "(no member)",
|
|
|
|
|
dbus_message_get_error_name (message) ?
|
|
|
|
|
dbus_message_get_error_name (message) : "(no error name)");
|
|
|
|
|
|
2005-02-17 21:19:49 +00:00
|
|
|
if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
|
2003-04-14 02:29:21 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2003-10-22 16:01:08 +00:00
|
|
|
if (bus_connection_is_active (connection))
|
|
|
|
|
{
|
|
|
|
|
if (!dbus_message_set_destination (message,
|
|
|
|
|
bus_connection_get_name (connection)))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-14 22:16:03 +00:00
|
|
|
/* bus driver never wants a reply */
|
|
|
|
|
dbus_message_set_no_reply (message, TRUE);
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
/* If security policy doesn't allow the message, we silently
|
|
|
|
|
* eat it; the driver doesn't care about getting a reply.
|
|
|
|
|
*/
|
|
|
|
|
if (!bus_context_check_security_policy (bus_transaction_get_context (transaction),
|
2003-10-14 05:16:56 +00:00
|
|
|
transaction,
|
2003-09-21 19:53:56 +00:00
|
|
|
NULL, connection, connection, message, NULL))
|
2003-04-14 02:29:21 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return bus_transaction_send (transaction, connection, message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_transaction_send (BusTransaction *transaction,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
DBusMessage *message)
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
MessageToSend *to_send;
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
DBusList *link;
|
|
|
|
|
|
2003-08-18 15:27:33 +00:00
|
|
|
_dbus_verbose (" trying to add %s interface=%s member=%s error=%s to transaction%s\n",
|
2003-08-11 02:11:58 +00:00
|
|
|
dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ? "error" :
|
2003-04-17 04:25:45 +00:00
|
|
|
dbus_message_get_reply_serial (message) != 0 ? "reply" :
|
2003-04-10 05:12:19 +00:00
|
|
|
"message",
|
2003-08-18 15:27:33 +00:00
|
|
|
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)",
|
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_get_is_connected (connection) ?
|
|
|
|
|
"" : " (disconnected)");
|
2003-03-20 07:57:39 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (dbus_message_get_sender (message) != NULL);
|
2003-03-15 20:47:16 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!dbus_connection_get_is_connected (connection))
|
|
|
|
|
return TRUE; /* silently ignore disconnected connections */
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
to_send = dbus_new (MessageToSend, 1);
|
|
|
|
|
if (to_send == NULL)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
to_send->preallocated = dbus_connection_preallocate_send (connection);
|
|
|
|
|
if (to_send->preallocated == NULL)
|
|
|
|
|
{
|
|
|
|
|
dbus_free (to_send);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dbus_message_ref (message);
|
|
|
|
|
to_send->message = message;
|
|
|
|
|
to_send->transaction = transaction;
|
|
|
|
|
|
2003-03-16 21:01:57 +00:00
|
|
|
_dbus_verbose ("about to prepend message\n");
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
if (!_dbus_list_prepend (&d->transaction_messages, to_send))
|
|
|
|
|
{
|
|
|
|
|
message_to_send_free (connection, to_send);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-03-16 21:01:57 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose ("prepended message\n");
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
/* See if we already had this connection in the list
|
|
|
|
|
* for this transaction. If we have a pending message,
|
|
|
|
|
* then we should already be in transaction->connections
|
|
|
|
|
*/
|
|
|
|
|
link = _dbus_list_get_first_link (&d->transaction_messages);
|
|
|
|
|
_dbus_assert (link->data == to_send);
|
|
|
|
|
link = _dbus_list_get_next_link (&d->transaction_messages, link);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
MessageToSend *m = link->data;
|
|
|
|
|
DBusList *next = _dbus_list_get_next_link (&d->transaction_messages, link);
|
|
|
|
|
|
|
|
|
|
if (m->transaction == transaction)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
link = next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (link == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_list_prepend (&transaction->connections, connection))
|
|
|
|
|
{
|
|
|
|
|
_dbus_list_remove (&d->transaction_messages, to_send);
|
|
|
|
|
message_to_send_free (connection, to_send);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_cancel_transaction (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
link = _dbus_list_get_first_link (&d->transaction_messages);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
MessageToSend *m = link->data;
|
|
|
|
|
DBusList *next = _dbus_list_get_next_link (&d->transaction_messages, link);
|
|
|
|
|
|
|
|
|
|
if (m->transaction == transaction)
|
|
|
|
|
{
|
|
|
|
|
_dbus_list_remove_link (&d->transaction_messages,
|
|
|
|
|
link);
|
|
|
|
|
|
|
|
|
|
message_to_send_free (connection, m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
link = next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_transaction_cancel_and_free (BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
|
|
|
_dbus_verbose ("TRANSACTION: cancelled\n");
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
while ((connection = _dbus_list_pop_first (&transaction->connections)))
|
|
|
|
|
connection_cancel_transaction (connection, transaction);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (transaction->connections == NULL);
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
_dbus_list_foreach (&transaction->cancel_hooks,
|
|
|
|
|
cancel_hook_cancel, NULL);
|
|
|
|
|
|
|
|
|
|
free_cancel_hooks (transaction);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_free (transaction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
connection_execute_transaction (DBusConnection *connection,
|
|
|
|
|
BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
DBusList *link;
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
/* Send the queue in order (FIFO) */
|
|
|
|
|
link = _dbus_list_get_last_link (&d->transaction_messages);
|
|
|
|
|
while (link != NULL)
|
|
|
|
|
{
|
|
|
|
|
MessageToSend *m = link->data;
|
|
|
|
|
DBusList *prev = _dbus_list_get_prev_link (&d->transaction_messages, link);
|
|
|
|
|
|
|
|
|
|
if (m->transaction == transaction)
|
|
|
|
|
{
|
|
|
|
|
_dbus_list_remove_link (&d->transaction_messages,
|
|
|
|
|
link);
|
|
|
|
|
|
2003-03-20 07:57:39 +00:00
|
|
|
_dbus_assert (dbus_message_get_sender (m->message) != NULL);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_connection_send_preallocated (connection,
|
|
|
|
|
m->preallocated,
|
|
|
|
|
m->message,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
m->preallocated = NULL; /* so we don't double-free it */
|
|
|
|
|
|
|
|
|
|
message_to_send_free (connection, m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
link = prev;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bus_transaction_execute_and_free (BusTransaction *transaction)
|
|
|
|
|
{
|
|
|
|
|
/* For each connection in transaction->connections
|
|
|
|
|
* send the messages
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
|
|
|
_dbus_verbose ("TRANSACTION: executing\n");
|
2003-03-13 00:56:43 +00:00
|
|
|
|
|
|
|
|
while ((connection = _dbus_list_pop_first (&transaction->connections)))
|
|
|
|
|
connection_execute_transaction (connection, transaction);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (transaction->connections == NULL);
|
|
|
|
|
|
2003-04-11 00:03:06 +00:00
|
|
|
free_cancel_hooks (transaction);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
dbus_free (transaction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
bus_connection_remove_transactions (DBusConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
MessageToSend *to_send;
|
|
|
|
|
BusConnectionData *d;
|
|
|
|
|
|
|
|
|
|
d = BUS_CONNECTION_DATA (connection);
|
|
|
|
|
_dbus_assert (d != NULL);
|
|
|
|
|
|
|
|
|
|
while ((to_send = _dbus_list_get_first (&d->transaction_messages)))
|
|
|
|
|
{
|
|
|
|
|
/* only has an effect for the first MessageToSend listing this transaction */
|
|
|
|
|
_dbus_list_remove (&to_send->transaction->connections,
|
|
|
|
|
connection);
|
|
|
|
|
|
|
|
|
|
_dbus_list_remove (&d->transaction_messages, to_send);
|
|
|
|
|
message_to_send_free (connection, to_send);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts the DBusError to a message reply
|
|
|
|
|
*/
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_transaction_send_error_reply (BusTransaction *transaction,
|
|
|
|
|
DBusConnection *connection,
|
|
|
|
|
const DBusError *error,
|
|
|
|
|
DBusMessage *in_reply_to)
|
|
|
|
|
{
|
|
|
|
|
DBusMessage *reply;
|
2003-03-26 03:58:11 +00:00
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
_dbus_assert (error != NULL);
|
|
|
|
|
_DBUS_ASSERT_ERROR_IS_SET (error);
|
2003-08-18 22:43:30 +00:00
|
|
|
|
2003-04-27 06:25:42 +00:00
|
|
|
_dbus_verbose ("Sending error reply %s \"%s\"\n",
|
|
|
|
|
error->name, error->message);
|
|
|
|
|
|
2003-08-11 02:11:58 +00:00
|
|
|
reply = dbus_message_new_error (in_reply_to,
|
|
|
|
|
error->name,
|
|
|
|
|
error->message);
|
2003-03-13 00:56:43 +00:00
|
|
|
if (reply == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2003-04-14 02:29:21 +00:00
|
|
|
if (!bus_transaction_send_from_driver (transaction, connection, reply))
|
2003-03-13 00:56:43 +00:00
|
|
|
{
|
|
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-02 20:14:52 +00:00
|
|
|
dbus_message_unref (reply);
|
|
|
|
|
|
2003-03-13 00:56:43 +00:00
|
|
|
return TRUE;
|
2003-01-24 23:51:59 +00:00
|
|
|
}
|
2003-04-11 00:03:06 +00:00
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
bus_transaction_add_cancel_hook (BusTransaction *transaction,
|
|
|
|
|
BusTransactionCancelFunction cancel_function,
|
|
|
|
|
void *data,
|
|
|
|
|
DBusFreeFunction free_data_function)
|
|
|
|
|
{
|
|
|
|
|
CancelHook *ch;
|
|
|
|
|
|
|
|
|
|
ch = dbus_new (CancelHook, 1);
|
|
|
|
|
if (ch == NULL)
|
|
|
|
|
return FALSE;
|
2003-10-16 Havoc Pennington <hp@redhat.com>
* bus/connection.c (bus_pending_reply_expired): either cancel or
execute, not both
(bus_connections_check_reply): use unlink, not remove_link, as we
don't want to free the link; fixes double free mess
* dbus/dbus-pending-call.c (dbus_pending_call_block): fix in case
where no reply was received
* dbus/dbus-connection.c (_dbus_pending_call_complete_and_unlock):
fix a refcount leak
* bus/signals.c (match_rule_matches): add special cases for the
bus driver, so you can match on sender/destination for it.
* dbus/dbus-sysdeps.c (_dbus_abort): print backtrace if
DBUS_PRINT_BACKTRACE is set
* dbus/dbus-internals.c: add pid to assertion failure messages
* dbus/dbus-connection.c: add message type code to the debug spew
* glib/dbus-gproxy.c (gproxy_get_match_rule): match rules want
sender=foo not service=foo
* dbus/dbus-bus.c (dbus_bus_get): if the activation bus is the
session bus but DBUS_SESSION_BUS_ADDRESS isn't set, use
DBUS_ACTIVATION_ADDRESS instead
* bus/activation.c: set DBUS_SESSION_BUS_ADDRESS,
DBUS_SYSTEM_BUS_ADDRESS if appropriate
* bus/bus.c (bus_context_new): handle OOM copying bus type into
context struct
* dbus/dbus-message.c (dbus_message_iter_get_object_path): new function
(dbus_message_iter_get_object_path_array): new function (half
finished, disabled for the moment)
* glib/dbus-gproxy.c (dbus_gproxy_end_call): properly handle
DBUS_MESSAGE_TYPE_ERROR
* tools/dbus-launch.c (babysit): support DBUS_DEBUG_OUTPUT to
avoid redirecting stderr to /dev/null
(babysit): close stdin if not doing the "exit_with_session" thing
* dbus/dbus-sysdeps.c (_dbus_become_daemon): delete some leftover
debug code; change DBUS_DEBUG_OUTPUT to only enable stderr, not
stdout/stdin, so things don't get confused
* bus/system.conf.in: fix to allow replies, I modified .conf
instead of .conf.in again.
2003-10-16 06:34:51 +00:00
|
|
|
|
|
|
|
|
_dbus_verbose (" adding cancel hook function = %p data = %p\n",
|
|
|
|
|
cancel_function, data);
|
2003-04-11 00:03:06 +00:00
|
|
|
|
|
|
|
|
ch->cancel_function = cancel_function;
|
|
|
|
|
ch->data = data;
|
|
|
|
|
ch->free_data_function = free_data_function;
|
|
|
|
|
|
|
|
|
|
/* It's important that the hooks get run in reverse order that they
|
|
|
|
|
* were added
|
|
|
|
|
*/
|
|
|
|
|
if (!_dbus_list_prepend (&transaction->cancel_hooks, ch))
|
|
|
|
|
{
|
|
|
|
|
dbus_free (ch);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|