[ServiceManager] Eliminate parent-child relationship between services
This change eliminates the property that non-singleton services are owned by the first service that connects to them. Instead, singleton and non-singleton services are treated identically by the Service Manager: they go away either (1) when the service requests so or (2) when the Service Manager itself goes away. The motivation for this change is that (a) there are situations where this "tree ownership" model doesn't make sense (see linked bug), and (b) there is nothing currently in the codebase that is utilizing the tree ownership model. If desired, the tree ownership model could be resurrected on a per-service basis by adding a "session manager" attribute to a service's manifest, which would denote that that service should own all of the services that it directly or transitively connects to. This CL also changes Service Manager's destructor to perform two-phase shutdown on its owned Instances. This change eliminates possible deadlock in the following situation: - An Instance A blocks in its destructor for its Runner to complete - That Runner blocks completion on the corresponding Service A shutting down - Service A blocks its shutdown on some distinct Service B shutting down - Service B is waiting to receive a connection error in order to initiate shutdown - ServiceManager never deletes Instance B since it is blocked waiting for the destructor of Instance A to return An example of such a situation is found in connect_test_package.cc: ConnectTestService clears its ProvidedService instances in its OnStop() method, while ProvidedService does not exit its destructor until it receives a connection error. Before this CL, deadlock was not tickled because the ProvidedServices were always killed when the first service that connected to them was killed, which happened to be before ConnectTestService was killed. BUG=672863 Review-Url: https://codereview.chromium.org/2572803002 Cr-Commit-Position: refs/heads/master@{#438780}
Showing
Please register or sign in to comment