[banshee/gio-hardware] [SourceManager] More thread safeness
- From: Alex Launi <alexlauni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gio-hardware] [SourceManager] More thread safeness
- Date: Fri, 13 Aug 2010 15:26:29 +0000 (UTC)
commit 8ebad500d87e196e694d02df847644c0918ae65e
Author: Gabriel Burt <gabriel burt gmail com>
Date: Wed Aug 11 09:26:35 2010 -0700
[SourceManager] More thread safeness
Fixes bug introduced by lazy loading sources, where they could be lazy
loaded during the delayed initialization of another extension, thereby
modifying the enumerable of extensions to delayed initialize (bgo#626596)
.../Banshee.ServiceStack/ServiceManager.cs | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs b/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
index cd38f1f..ed16579 100644
--- a/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
+++ b/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs
@@ -27,6 +27,7 @@
//
using System;
+using System.Linq;
using System.IO;
using System.Collections.Generic;
@@ -251,7 +252,8 @@ namespace Banshee.ServiceStack
if (!delayed_initialized) {
have_client = true;
var initialized = new HashSet <string> ();
- foreach (IService service in services.Values) {
+ var to_initialize = services.Values.ToList ();
+ foreach (IService service in to_initialize) {
if (!initialized.Contains (service.ServiceName)) {
DelayedInitialize (service);
initialized.Add (service.ServiceName);
@@ -340,13 +342,15 @@ namespace Banshee.ServiceStack
public static T Get<T> () where T : class, IService
{
- Type type = typeof (T);
- T service = Get (type.Name) as T;
- if (service == null && type.GetInterface ("Banshee.ServiceStack.IRegisterOnDemandService") != null) {
- return RegisterService (type) as T;
- }
+ lock (self_mutex) {
+ Type type = typeof (T);
+ T service = Get (type.Name) as T;
+ if (service == null && type.GetInterface ("Banshee.ServiceStack.IRegisterOnDemandService") != null) {
+ return RegisterService (type) as T;
+ }
- return service;
+ return service;
+ }
}
private static void Add (IService service)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]