Browse Source

cmCTestMultiProcessHandler: Use cm::uv_loop_ptr abstraction

This ensures all loop resources are released.
Brad King 2 years ago
parent
commit
451429e19c

+ 4 - 4
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -142,10 +142,10 @@ void cmCTestMultiProcessHandler::RunTests()
 #endif
   this->TestHandler->SetMaxIndex(this->FindMaxIndex());
 
-  uv_loop_init(&this->Loop);
+  this->Loop.init();
   this->StartNextTests();
-  uv_run(&this->Loop, UV_RUN_DEFAULT);
-  uv_loop_close(&this->Loop);
+  uv_run(this->Loop, UV_RUN_DEFAULT);
+  this->Loop.reset();
 
   if (!this->StopTimePassed && !this->CheckStopOnFailure()) {
     assert(this->Complete());
@@ -618,7 +618,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
       milliseconds = 10;
     }
     if (this->TestLoadRetryTimer.get() == nullptr) {
-      this->TestLoadRetryTimer.init(this->Loop, this);
+      this->TestLoadRetryTimer.init(*this->Loop, this);
     }
     this->TestLoadRetryTimer.start(
       &cmCTestMultiProcessHandler::OnTestLoadRetryCB, milliseconds, 0);

+ 1 - 1
Source/CTest/cmCTestMultiProcessHandler.h

@@ -201,7 +201,7 @@ protected:
   size_t ParallelLevel; // max number of process that can be run at once
   unsigned long TestLoad;
   unsigned long FakeLoadForTesting;
-  uv_loop_t Loop;
+  cm::uv_loop_ptr Loop;
   cm::uv_timer_ptr TestLoadRetryTimer;
   cmCTestTestHandler* TestHandler;
   cmCTest* CTest;

+ 2 - 1
Source/CTest/cmCTestRunTest.cxx

@@ -25,6 +25,7 @@
 #include "cmProcess.h"
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
+#include "cmUVHandlePtr.h"
 #include "cmWorkingDirectory.h"
 
 cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler,
@@ -890,7 +891,7 @@ bool cmCTestRunTest::ForkProcess()
   this->TestResult.Environment.erase(this->TestResult.Environment.length() -
                                      1);
 
-  return this->TestProcess->StartProcess(this->MultiTestHandler.Loop,
+  return this->TestProcess->StartProcess(*this->MultiTestHandler.Loop,
                                          &this->TestProperties->Affinity);
 }