Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1459)

Unified Diff: src/service.cc

Issue 5380002: cashew: defer all D-Bus signal processing to main loop (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git@master
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/service.cc
diff --git a/src/service.cc b/src/service.cc
index 797189b63aacdc4e2210b3487e2057f1aa673518..7427022e31b442213f7c57f3ae29a793ee75d725 100644
--- a/src/service.cc
+++ b/src/service.cc
@@ -92,6 +92,7 @@ Service::Service(ServiceManager * const parent,
if (get_properties_source_id_ == 0) {
LOG(ERROR) << path_ << ": ctor: g_idle_add failed";
}
+ property_changed_handler_.delegate(this);
}
Service::~Service() {
@@ -182,6 +183,21 @@ Service::ConnectivityState Service::GetConnectivityState() const {
void Service::PropertyChanged(const std::string& property_name,
const DBus::Variant& new_value) {
DLOG(INFO) << path_ << ": PropertyChanged: property_name = " << property_name;
+ // Queue a tuple representing this signal for later processing from the glib
+ // main loop. We do this to avoid libdbus-c++ deadlocks that can occur when
+ // sending a dbus message from within a dbus callback like this one.
+ PropertyChangedSignal signal(property_name, new_value);
+ property_changed_handler_.EnqueueSignal(signal);
+}
+
+// PropertyChangedDelegate methods
+
+void Service::OnPropertyChanged(const PropertyChangedHandler *handler,
+ const std::string& property_name,
+ const DBus::Variant& new_value) {
+ DCHECK(handler == &property_changed_handler_);
+ DLOG(INFO) << path_ << ": OnPropertyChanged: property_name = "
+ << property_name;
if (property_name == kFlimflamServiceDeviceProperty) {
OnDeviceUpdate(new_value.reader().get_path());
} else if (property_name == kFlimflamServiceStateProperty) {
« src/property_changed_handler.cc ('K') | « src/service.h ('k') | src/service_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698