Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2013-02-12 17:25:00 +0400
committerMarek Safar <marek.safar@gmail.com>2013-02-12 17:25:58 +0400
commitc1437f237f63608c7bc8d297dbadd7acccf4d104 (patch)
tree38777c1f9ac1e9d205880fe3b57da939842ba383 /mcs/class/corlib/System.Threading.Tasks
parent65518ad2cac80ef19e4d81bffa10016b8ca3774b (diff)
Fix TaskCreationOptions.AttachedToParent to avoid NRE on TaskCreationOptions.DenyChildAttach and deadlock on Wait
Diffstat (limited to 'mcs/class/corlib/System.Threading.Tasks')
-rw-r--r--mcs/class/corlib/System.Threading.Tasks/Task.cs29
1 files changed, 17 insertions, 12 deletions
diff --git a/mcs/class/corlib/System.Threading.Tasks/Task.cs b/mcs/class/corlib/System.Threading.Tasks/Task.cs
index 5011dde28b6..cf59c613845 100644
--- a/mcs/class/corlib/System.Threading.Tasks/Task.cs
+++ b/mcs/class/corlib/System.Threading.Tasks/Task.cs
@@ -150,10 +150,10 @@ namespace System.Threading.Tasks
// Process creationOptions
#if NET_4_5
- if (HasFlag (creationOptions, TaskCreationOptions.AttachedToParent)
- && parent != null && !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach))
+ if (parent != null && HasFlag (creationOptions, TaskCreationOptions.AttachedToParent)
+ && !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach))
#else
- if (HasFlag (creationOptions, TaskCreationOptions.AttachedToParent) && parent != null)
+ if (parent != null && HasFlag (creationOptions, TaskCreationOptions.AttachedToParent))
#endif
parent.AddChild ();
@@ -502,7 +502,11 @@ namespace System.Threading.Tasks
ProcessChildExceptions ();
Status = exSlot == null ? TaskStatus.RanToCompletion : TaskStatus.Faulted;
ProcessCompleteDelegates ();
- if (HasFlag (creationOptions, TaskCreationOptions.AttachedToParent) && parent != null)
+ if (parent != null &&
+#if NET_4_5
+ !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach) &&
+#endif
+ HasFlag (creationOptions, TaskCreationOptions.AttachedToParent))
parent.ChildCompleted (this.Exception);
}
}
@@ -532,6 +536,15 @@ namespace System.Threading.Tasks
Status = TaskStatus.WaitingForChildrenToComplete;
}
+ // Tell parent that we are finished
+ if (parent != null && HasFlag (creationOptions, TaskCreationOptions.AttachedToParent) &&
+#if NET_4_5
+ !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach) &&
+#endif
+ status != TaskStatus.WaitingForChildrenToComplete) {
+ parent.ChildCompleted (this.Exception);
+ }
+
// Completions are already processed when task is canceled or faulted
if (status == TaskStatus.RanToCompletion)
ProcessCompleteDelegates ();
@@ -544,11 +557,6 @@ namespace System.Threading.Tasks
if (cancellationRegistration.HasValue)
cancellationRegistration.Value.Dispose ();
-
- // Tell parent that we are finished
- if (HasFlag (creationOptions, TaskCreationOptions.AttachedToParent) && parent != null && status != TaskStatus.WaitingForChildrenToComplete) {
- parent.ChildCompleted (this.Exception);
- }
}
void ProcessCompleteDelegates ()
@@ -661,9 +669,6 @@ namespace System.Threading.Tasks
if (exception != null)
throw exception;
- if (childTasks != null)
- childTasks.Wait ();
-
return result;
}