aboutsummaryrefslogtreecommitdiffstats
path: root/fsousaged
diff options
context:
space:
mode:
authorSimon Busch <morphis@gravedo.de>2011-07-12 12:37:13 +0200
committerSimon Busch <morphis@gravedo.de>2011-07-12 12:37:13 +0200
commit5d1d96170fef3606a3e7a8eb0d687167fedf28a3 (patch)
tree266af050bef25f56d3932e987d57ca82b659c93f /fsousaged
parenta804a656083523efcedba45091f760324362303f (diff)
downloadcornucopia-5d1d96170fef3606a3e7a8eb0d687167fedf28a3.tar.gz
cornucopia-5d1d96170fef3606a3e7a8eb0d687167fedf28a3.tar.bz2
cornucopia-5d1d96170fef3606a3e7a8eb0d687167fedf28a3.zip
fsousaged: dbus_serivce: make shadow resource handling finally work
If a shadow resource is pinged but never registers its resource the daemon will not die anymore. It will wait for about 10 seconds for the resource to register and then abort resource enablement process.
Diffstat (limited to 'fsousaged')
-rw-r--r--fsousaged/src/plugins/dbus_service/resource.vala27
1 files changed, 26 insertions, 1 deletions
diff --git a/fsousaged/src/plugins/dbus_service/resource.vala b/fsousaged/src/plugins/dbus_service/resource.vala
index 6663daac..cf8f1959 100644
--- a/fsousaged/src/plugins/dbus_service/resource.vala
+++ b/fsousaged/src/plugins/dbus_service/resource.vala
@@ -317,9 +317,34 @@ public class Resource : IResource, Object
#if DEBUG
message( "shadowResourceEnabled" );
#endif
+
+ // Wait until the resource has registered or registration has timed out
+ int retries = 0;
+ Timeout.add( 1, () => {
+ if ( retries > 10 )
+ {
+ instance.logger.error( "Can't enable resource '$name' as it has never registered!" );
+ return false;
+ }
+
+ if ( proxy != null )
+ {
+ assert( instance.logger.debug( @"DBus proxy for resource '$name' is now available." ) );
+ enable.callback();
+ return false;
+ }
+
+ retries++;
+ return true;
+ });
+ yield;
}
- assert( proxy != null );
+ // Ensure that we have a dbus connection for our resource
+ if ( proxy == null )
+ {
+ throw new FreeSmartphone.ResourceError.UNABLE_TO_ENABLE( @"Can't enable resource '$name'" );
+ }
try
{