Browse Source

Fixed thread-safety problem in SearchClassReturnType.

Don't set 'Strict' to true when creating new Boo project.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4412 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
5467f54ba2
  1. 1
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs
  2. 20
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/SearchClassReturnType.cs

1
src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/BooProject.cs

@ -71,7 +71,6 @@ namespace Grunwald.BooBinding
PropertyStorageLocations.ConfigurationSpecific, false); PropertyStorageLocations.ConfigurationSpecific, false);
SetProperty("Release", null, "DefineConstants", "TRACE", SetProperty("Release", null, "DefineConstants", "TRACE",
PropertyStorageLocations.ConfigurationSpecific, false); PropertyStorageLocations.ConfigurationSpecific, false);
SetProperty("Strict", "True");
} }
void AddReference(string assembly) void AddReference(string assembly)

20
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/SearchClassReturnType.cs

@ -57,7 +57,16 @@ namespace ICSharpCode.SharpDevelop.Dom
} }
volatile IReturnType cachedBaseType; volatile IReturnType cachedBaseType;
int isSearching; // 0=false, 1=true
//int isSearching; // 0=false, 1=true
// Required to prevent stack overflow on inferrence cycles
// replaces old 'isSearching' flag which wasn't thread-safe
[ThreadStatic] static BusyManager _busyManager;
static BusyManager busyManager {
get { return _busyManager ?? (_busyManager = new BusyManager()); }
}
void ClearCachedBaseType() void ClearCachedBaseType()
{ {
@ -69,9 +78,10 @@ namespace ICSharpCode.SharpDevelop.Dom
IReturnType type = cachedBaseType; IReturnType type = cachedBaseType;
if (type != null) if (type != null)
return type; return type;
if (Interlocked.CompareExchange(ref isSearching, 1, 0) != 0) using (var l = busyManager.Enter(this)) {
return null; // abort if called recursively on the same thread
try { if (!l.Success)
return null;
SearchTypeRequest request = new SearchTypeRequest(name, typeParameterCount, declaringClass, caretLine, caretColumn); SearchTypeRequest request = new SearchTypeRequest(name, typeParameterCount, declaringClass, caretLine, caretColumn);
if (!lookForInnerClassesInDeclaringClass) { if (!lookForInnerClassesInDeclaringClass) {
// skip looking for inner classes by adjusting the CurrentType for the lookup // skip looking for inner classes by adjusting the CurrentType for the lookup
@ -82,8 +92,6 @@ namespace ICSharpCode.SharpDevelop.Dom
if (type != null) if (type != null)
DomCache.RegisterForClear(ClearCachedBaseType); DomCache.RegisterForClear(ClearCachedBaseType);
return type; return type;
} finally {
isSearching = 0;
} }
} }
} }

Loading…
Cancel
Save