Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit b551314

Browse files
obonessavornicesei
authored andcommitted
Avoid race condition between the Stopped and Abort methods that may lead to NullReferenceExceptions being triggered
1 parent 8e5b0bc commit b551314

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

project/core/ProjectIntegrator.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ private void Stopped()
358358
{
359359
// the state was set to 'Stopping', so set it to 'Stopped'
360360
state = ProjectIntegratorState.Stopped;
361-
thread = null;
361+
lock(this)
362+
thread = null;
363+
362364
// Ensure that any queued integrations are cleared for this project.
363365
integrationQueue.RemoveProject(project);
364366
Log.Info("Integrator for project: " + project.Name + " is now stopped.");
@@ -393,10 +395,13 @@ public void Stop(bool restarting)
393395
/// </summary>
394396
public void Abort()
395397
{
396-
if (thread != null)
398+
lock(this)
397399
{
398-
Log.Info("Aborting integrator for project: " + project.Name);
399-
thread.Abort();
400+
if (thread != null)
401+
{
402+
Log.Info("Aborting integrator for project: " + project.Name);
403+
thread.Abort();
404+
}
400405
}
401406
}
402407

0 commit comments

Comments
 (0)