summaryrefslogtreecommitdiff
path: root/src/burn/engine/core.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/burn/engine/core.cpp')
-rw-r--r--src/burn/engine/core.cpp54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/burn/engine/core.cpp b/src/burn/engine/core.cpp
index c1e3a12c..716e5af1 100644
--- a/src/burn/engine/core.cpp
+++ b/src/burn/engine/core.cpp
@@ -12,6 +12,9 @@ struct BURN_CACHE_THREAD_CONTEXT
12}; 12};
13 13
14 14
15static PFN_PROCWAITFORCOMPLETION vpfnProcWaitForCompletion = ProcWaitForCompletion;
16
17
15// internal function declarations 18// internal function declarations
16 19
17static HRESULT CoreRecreateCommandLine( 20static HRESULT CoreRecreateCommandLine(
@@ -65,9 +68,6 @@ static HRESULT DetectPackagePayloadsCached(
65static DWORD WINAPI CacheThreadProc( 68static DWORD WINAPI CacheThreadProc(
66 __in LPVOID lpThreadParameter 69 __in LPVOID lpThreadParameter
67 ); 70 );
68static HRESULT WaitForCacheThread(
69 __in HANDLE hCacheThread
70 );
71static void LogPackages( 71static void LogPackages(
72 __in_opt const BURN_PACKAGE* pUpgradeBundlePackage, 72 __in_opt const BURN_PACKAGE* pUpgradeBundlePackage,
73 __in_opt const BURN_PACKAGE* pForwardCompatibleBundlePackage, 73 __in_opt const BURN_PACKAGE* pForwardCompatibleBundlePackage,
@@ -636,6 +636,7 @@ extern "C" HRESULT CoreApply(
636 BURN_APPLY_CONTEXT applyContext = { }; 636 BURN_APPLY_CONTEXT applyContext = { };
637 BOOL fDeleteApplyCs = FALSE; 637 BOOL fDeleteApplyCs = FALSE;
638 BURN_CACHE_THREAD_CONTEXT cacheThreadContext = { }; 638 BURN_CACHE_THREAD_CONTEXT cacheThreadContext = { };
639 DWORD dwCacheExitCode = 0;
639 BOOL fRollbackCache = FALSE; 640 BOOL fRollbackCache = FALSE;
640 DWORD dwPhaseCount = 0; 641 DWORD dwPhaseCount = 0;
641 BOOTSTRAPPER_APPLYCOMPLETE_ACTION applyCompleteAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE; 642 BOOTSTRAPPER_APPLYCOMPLETE_ACTION applyCompleteAction = BOOTSTRAPPER_APPLYCOMPLETE_ACTION_NONE;
@@ -744,7 +745,10 @@ extern "C" HRESULT CoreApply(
744 // If we're not caching in parallel, wait for the cache thread to terminate. 745 // If we're not caching in parallel, wait for the cache thread to terminate.
745 if (!pEngineState->fParallelCacheAndExecute) 746 if (!pEngineState->fParallelCacheAndExecute)
746 { 747 {
747 hr = WaitForCacheThread(applyContext.hCacheThread); 748 hr = ThrdWaitForCompletion(applyContext.hCacheThread, INFINITE, &dwCacheExitCode);
749 ExitOnFailure(hr, "Failed to wait for cache thread before execute.");
750
751 hr = (HRESULT)dwCacheExitCode;
748 ExitOnFailure(hr, "Failed while caching, aborting execution."); 752 ExitOnFailure(hr, "Failed while caching, aborting execution.");
749 753
750 ReleaseHandle(applyContext.hCacheThread); 754 ReleaseHandle(applyContext.hCacheThread);
@@ -761,10 +765,12 @@ extern "C" HRESULT CoreApply(
761 // Wait for cache thread to terminate, this should return immediately unless we're waiting for layout to complete. 765 // Wait for cache thread to terminate, this should return immediately unless we're waiting for layout to complete.
762 if (applyContext.hCacheThread) 766 if (applyContext.hCacheThread)
763 { 767 {
764 HRESULT hrCached = WaitForCacheThread(applyContext.hCacheThread); 768 HRESULT hrCached = ThrdWaitForCompletion(applyContext.hCacheThread, INFINITE, &dwCacheExitCode);
769 ExitOnFailure(hrCached, "Failed to wait for cache thread after execute.");
770
765 if (SUCCEEDED(hr)) 771 if (SUCCEEDED(hr))
766 { 772 {
767 hr = hrCached; 773 hr = (HRESULT)dwCacheExitCode;
768 } 774 }
769 } 775 }
770 776
@@ -1940,6 +1946,22 @@ LExit:
1940 return hr; 1946 return hr;
1941} 1947}
1942 1948
1949extern "C" void CoreFunctionOverride(
1950 __in_opt PFN_PROCWAITFORCOMPLETION pfnProcWaitForCompletion
1951 )
1952{
1953 vpfnProcWaitForCompletion = pfnProcWaitForCompletion;
1954}
1955
1956extern "C" HRESULT DAPI CoreWaitForProcCompletion(
1957 __in HANDLE hProcess,
1958 __in DWORD dwTimeout,
1959 __out DWORD* pdwReturnCode
1960 )
1961{
1962 return vpfnProcWaitForCompletion(hProcess, dwTimeout, pdwReturnCode);
1963}
1964
1943// internal helper functions 1965// internal helper functions
1944 1966
1945static HRESULT AppendEscapedArgumentToCommandLine( 1967static HRESULT AppendEscapedArgumentToCommandLine(
@@ -2268,26 +2290,6 @@ LExit:
2268 return (DWORD)hr; 2290 return (DWORD)hr;
2269} 2291}
2270 2292
2271static HRESULT WaitForCacheThread(
2272 __in HANDLE hCacheThread
2273 )
2274{
2275 HRESULT hr = S_OK;
2276
2277 if (WAIT_OBJECT_0 != ::WaitForSingleObject(hCacheThread, INFINITE))
2278 {
2279 ExitWithLastError(hr, "Failed to wait for cache thread to terminate.");
2280 }
2281
2282 if (!::GetExitCodeThread(hCacheThread, (DWORD*)&hr))
2283 {
2284 ExitWithLastError(hr, "Failed to get cache thread exit code.");
2285 }
2286
2287LExit:
2288 return hr;
2289}
2290
2291static void LogPackages( 2293static void LogPackages(
2292 __in_opt const BURN_PACKAGE* pUpgradeBundlePackage, 2294 __in_opt const BURN_PACKAGE* pUpgradeBundlePackage,
2293 __in_opt const BURN_PACKAGE* pForwardCompatibleBundlePackage, 2295 __in_opt const BURN_PACKAGE* pForwardCompatibleBundlePackage,