diff options
author | cmasone@chromium.org <cmasone@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 06:34:59 +0000 |
---|---|---|
committer | cmasone@chromium.org <cmasone@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 06:34:59 +0000 |
commit | e282490e359a536c91b15c9a9023cc798fab303b (patch) | |
tree | 1dfee9533ded06413b5b713f246a317a67c47ddd /dbus/bus.cc | |
parent | 6bedbeffa4fa25ba16d50253dcc7c1aec5ac4702 (diff) | |
download | chromium_src-e282490e359a536c91b15c9a9023cc798fab303b.zip chromium_src-e282490e359a536c91b15c9a9023cc798fab303b.tar.gz chromium_src-e282490e359a536c91b15c9a9023cc798fab303b.tar.bz2 |
Allow Chromium's DBus service ownership to be stealable
We've seen some cases in tests where a Chromium process winds up in a
temporarily unkillable state, causing the dbus-daemon to believe that
it still actively owns org.chromium.LibCrosService. This makes
attempts to restart the UI fail, as the browser dies when it cannot
take ownership of this service name. The reason it can't is because
Chromium currently doesn't allow other processes to steal ownership --
and the unkillable process is holding onto the token.
This can be remedied by providing certain options when ownership of
the service name is taken, options that allow other processes to seize
ownership if they so choose. The ramifications of this are discussed
further in the bug.
BUG=chromium:261381
TEST=new unit test in dbus_unittest
TEST=run the following as chronos on a device: "gdbus call --system --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.RequestName org.chromium.LibCrosService 7"
TEST=This should return (uint32 1,)
Review URL: https://chromiumcodereview.appspot.com/20555003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214589 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/bus.cc')
-rw-r--r-- | dbus/bus.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/dbus/bus.cc b/dbus/bus.cc index 2be649e..ec2417e 100644 --- a/dbus/bus.cc +++ b/dbus/bus.cc @@ -501,21 +501,23 @@ void Bus::ShutdownOnDBusThreadAndBlock() { } void Bus::RequestOwnership(const std::string& service_name, + ServiceOwnershipOptions options, OnOwnershipCallback on_ownership_callback) { AssertOnOriginThread(); PostTaskToDBusThread(FROM_HERE, base::Bind( &Bus::RequestOwnershipInternal, - this, service_name, on_ownership_callback)); + this, service_name, options, on_ownership_callback)); } void Bus::RequestOwnershipInternal(const std::string& service_name, + ServiceOwnershipOptions options, OnOwnershipCallback on_ownership_callback) { AssertOnDBusThread(); bool success = Connect(); if (success) - success = RequestOwnershipAndBlock(service_name); + success = RequestOwnershipAndBlock(service_name, options); PostTaskToOriginThread(FROM_HERE, base::Bind(on_ownership_callback, @@ -523,7 +525,8 @@ void Bus::RequestOwnershipInternal(const std::string& service_name, success)); } -bool Bus::RequestOwnershipAndBlock(const std::string& service_name) { +bool Bus::RequestOwnershipAndBlock(const std::string& service_name, + ServiceOwnershipOptions options) { DCHECK(connection_); // dbus_bus_request_name() is a blocking call. AssertOnDBusThread(); @@ -536,7 +539,7 @@ bool Bus::RequestOwnershipAndBlock(const std::string& service_name) { ScopedDBusError error; const int result = dbus_bus_request_name(connection_, service_name.c_str(), - DBUS_NAME_FLAG_DO_NOT_QUEUE, + options, error.get()); if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { LOG(ERROR) << "Failed to get the ownership of " << service_name << ": " @@ -568,7 +571,8 @@ bool Bus::ReleaseOwnership(const std::string& service_name) { return true; } else { LOG(ERROR) << "Failed to release the ownership of " << service_name << ": " - << (error.is_set() ? error.message() : ""); + << (error.is_set() ? error.message() : "") + << ", result code: " << result; return false; } } |