diff options
author | Havoc Pennington <hp@redhat.com> | 2003-10-16 06:34:51 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-10-16 06:34:51 +0000 |
commit | d6e1b2adb3d8e51ce1bb47295cef12d9fe1a15a8 (patch) | |
tree | d94b220a2886b384ddc4f55df4689d79430a6399 /bus | |
parent | 9b9dd4b80eb2753fc67bed1f48eef89674ba968e (diff) |
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.
Diffstat (limited to 'bus')
-rw-r--r-- | bus/activation.c | 15 | ||||
-rw-r--r-- | bus/bus.c | 6 | ||||
-rw-r--r-- | bus/connection.c | 109 | ||||
-rw-r--r-- | bus/signals.c | 36 | ||||
-rw-r--r-- | bus/system.conf.in | 2 |
5 files changed, 137 insertions, 31 deletions
diff --git a/bus/activation.c b/bus/activation.c index 91d3c116..5588ed86 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -482,12 +482,25 @@ child_setup (void *data) */ if (!_dbus_setenv ("DBUS_ACTIVATION_ADDRESS", activation->server_address)) _dbus_exit (1); - + type = bus_context_get_type (activation->context); if (type != NULL) { if (!_dbus_setenv ("DBUS_BUS_TYPE", type)) _dbus_exit (1); + + if (strcmp (type, "session") == 0) + { + if (!_dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", + activation->server_address)) + _dbus_exit (1); + } + else if (strcmp (type, "system") == 0) + { + if (!_dbus_setenv ("DBUS_SYSTEM_BUS_ADDRESS", + activation->server_address)) + _dbus_exit (1); + } } } @@ -37,6 +37,7 @@ struct BusContext { int refcount; char *type; + char *bus_env_var; char *address; char *pidfile; DBusLoop *loop; @@ -398,6 +399,11 @@ bus_context_new (const DBusString *config_file, /* note that type may be NULL */ context->type = _dbus_strdup (bus_config_parser_get_type (parser)); + if (bus_config_parser_get_type (parser) != NULL && context->type == NULL) + { + BUS_SET_OOM (error); + goto failed; + } /* We have to build the address backward, so that * <listen> later in the config file have priority diff --git a/bus/connection.c b/bus/connection.c index 1e562427..65ebdb28 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -54,7 +54,7 @@ struct BusConnections BusContext *context; DBusHashTable *completed_by_user; /**< Number of completed connections for each UID */ DBusTimeout *expire_timeout; /**< Timeout for expiring incomplete connections. */ - int stamp; /**< Incrementing number */ + int stamp; /**< Incrementing number */ BusExpireList *pending_replies; /**< List of pending replies */ }; @@ -1340,6 +1340,18 @@ bus_connections_check_limits (BusConnections *connections, return TRUE; } +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); +} + static dbus_bool_t bus_pending_reply_send_no_reply (BusConnections *connections, BusTransaction *transaction, @@ -1393,20 +1405,28 @@ bus_pending_reply_expired (BusExpireList *list, * leave it in the list to try expiring again later when we * get more memory. */ + + _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); + transaction = bus_transaction_new (connections->context); if (transaction == NULL) return; - if (bus_pending_reply_send_no_reply (connections, - transaction, - pending)) + if (!bus_pending_reply_send_no_reply (connections, + transaction, + pending)) { - _dbus_list_remove_link (&connections->pending_replies->items, - link); - dbus_free (pending); bus_transaction_cancel_and_free (transaction); + return; } - + + _dbus_list_remove_link (&connections->pending_replies->items, + link); + bus_pending_reply_free (pending); bus_transaction_execute_and_free (transaction); } @@ -1418,6 +1438,9 @@ bus_connection_drop_pending_replies (BusConnections *connections, * do anything with it except check for pointer equality */ DBusList *link; + + _dbus_verbose ("Dropping pending replies that involve connection %p\n", + connection); link = _dbus_list_get_first_link (&connections->pending_replies->items); while (link != NULL) @@ -1433,16 +1456,27 @@ bus_connection_drop_pending_replies (BusConnections *connections, { /* We don't need to track this pending reply anymore */ + _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); + _dbus_list_remove_link (&connections->pending_replies->items, link); - dbus_free (pending); + bus_pending_reply_free (pending); } 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 */ - + _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); + pending->will_send_reply = NULL; pending->expire_item.added_tv_sec = 0; pending->expire_item.added_tv_usec = 0; @@ -1467,11 +1501,13 @@ cancel_pending_reply (void *data) { CancelPendingReplyData *d = data; + _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d); + if (!_dbus_list_remove (&d->connections->pending_replies->items, d->pending)) _dbus_assert_not_reached ("pending reply did not exist to be cancelled"); - dbus_free (d->pending); /* since it's been cancelled */ + bus_pending_reply_free (d->pending); /* since it's been cancelled */ } static void @@ -1479,6 +1515,8 @@ cancel_pending_reply_data_free (void *data) { CancelPendingReplyData *d = data; + _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d); + /* d->pending should be either freed or still * in the list of pending replies (owned by someone * else) @@ -1537,11 +1575,21 @@ bus_connections_expect_reply (BusConnections *connections, return FALSE; } +#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; + cprd = dbus_new0 (CancelPendingReplyData, 1); if (cprd == NULL) { BUS_SET_OOM (error); - dbus_free (pending); + bus_pending_reply_free (pending); return FALSE; } @@ -1550,7 +1598,7 @@ bus_connections_expect_reply (BusConnections *connections, { BUS_SET_OOM (error); dbus_free (cprd); - dbus_free (pending); + bus_pending_reply_free (pending); return FALSE; } @@ -1562,7 +1610,7 @@ bus_connections_expect_reply (BusConnections *connections, BUS_SET_OOM (error); _dbus_list_remove (&connections->pending_replies->items, pending); dbus_free (cprd); - dbus_free (pending); + bus_pending_reply_free (pending); return FALSE; } @@ -1572,10 +1620,12 @@ bus_connections_expect_reply (BusConnections *connections, _dbus_get_current_time (&pending->expire_item.added_tv_sec, &pending->expire_item.added_tv_usec); - pending->will_get_reply = will_get_reply; - pending->will_send_reply = will_send_reply; - pending->reply_serial = reply_serial; - + _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); + return TRUE; } @@ -1590,6 +1640,8 @@ cancel_check_pending_reply (void *data) { CheckPendingReplyData *d = data; + _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d); + _dbus_list_prepend_link (&d->connections->pending_replies->items, d->link); d->link = NULL; @@ -1600,11 +1652,16 @@ check_pending_reply_data_free (void *data) { CheckPendingReplyData *d = data; + _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d); + if (d->link != NULL) { BusPendingReply *pending = d->link->data; - - dbus_free (pending); + + _dbus_assert (_dbus_list_find_last (&d->connections->pending_replies->items, + pending) == NULL); + + bus_pending_reply_free (pending); _dbus_list_free_link (d->link); } @@ -1641,7 +1698,7 @@ bus_connections_check_reply (BusConnections *connections, pending->will_get_reply == receiving_reply && pending->will_send_reply == sending_reply) { - _dbus_verbose ("Found pending reply\n"); + _dbus_verbose ("Found pending reply with serial %u\n", reply_serial); break; } @@ -1676,8 +1733,11 @@ bus_connections_check_reply (BusConnections *connections, cprd->link = link; cprd->connections = connections; - _dbus_list_remove_link (&connections->pending_replies->items, - link); + _dbus_list_unlink (&connections->pending_replies->items, + link); + + _dbus_assert (_dbus_list_find_last (&connections->pending_replies->items, + link->data) == NULL); return TRUE; } @@ -2075,6 +2135,9 @@ bus_transaction_add_cancel_hook (BusTransaction *transaction, ch = dbus_new (CancelHook, 1); if (ch == NULL) return FALSE; + + _dbus_verbose (" adding cancel hook function = %p data = %p\n", + cancel_function, data); ch->cancel_function = cancel_function; ch->data = data; diff --git a/bus/signals.c b/bus/signals.c index 0fd4b514..9c0d31e2 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -1006,6 +1006,8 @@ connection_is_primary_owner (DBusConnection *connection, DBusString str; BusRegistry *registry; + _dbus_assert (connection != NULL); + registry = bus_connection_get_registry (connection); _dbus_string_init_const (&str, service_name); @@ -1028,6 +1030,11 @@ match_rule_matches (BusMatchRule *rule, * so FALSE if any of them don't match. */ + /* sender/addressed_recipient of #NULL may mean bus driver, + * or for addressed_recipient may mean a message with no + * specific recipient (i.e. a signal) + */ + if (rule->flags & BUS_MATCH_MESSAGE_TYPE) { _dbus_assert (rule->message_type != DBUS_MESSAGE_TYPE_INVALID); @@ -1068,8 +1075,17 @@ match_rule_matches (BusMatchRule *rule, { _dbus_assert (rule->sender != NULL); - if (!connection_is_primary_owner (sender, rule->sender)) - return FALSE; + if (sender == NULL) + { + if (strcmp (rule->sender, + DBUS_SERVICE_ORG_FREEDESKTOP_DBUS) != 0) + return FALSE; + } + else + { + if (!connection_is_primary_owner (sender, rule->sender)) + return FALSE; + } } if (rule->flags & BUS_MATCH_DESTINATION) @@ -1078,15 +1094,21 @@ match_rule_matches (BusMatchRule *rule, _dbus_assert (rule->destination != NULL); - if (addressed_recipient == NULL) - return FALSE; - destination = dbus_message_get_destination (message); if (destination == NULL) return FALSE; - if (!connection_is_primary_owner (addressed_recipient, rule->destination)) - return FALSE; + if (addressed_recipient == NULL) + { + if (strcmp (rule->destination, + DBUS_SERVICE_ORG_FREEDESKTOP_DBUS) != 0) + return FALSE; + } + else + { + if (!connection_is_primary_owner (addressed_recipient, rule->destination)) + return FALSE; + } } if (rule->flags & BUS_MATCH_PATH) diff --git a/bus/system.conf.in b/bus/system.conf.in index 8e2dbda9..167ac39f 100644 --- a/bus/system.conf.in +++ b/bus/system.conf.in @@ -44,6 +44,8 @@ even if they aren't in here --> <allow send_destination="org.freedesktop.DBus"/> <allow receive_sender="org.freedesktop.DBus"/> + <!-- valid replies are always allowed --> + <allow requested_reply="true"/> </policy> <!-- Config files are placed here that among other things, punch |