From: Steve MacLean Date: Tue, 18 Dec 2018 02:23:20 +0000 (-0500) Subject: Do not use CorHost2::m_fStarted to gate execution (dotnet/coreclr#20953) X-Git-Tag: submit/tizen/20210909.063632~11030^2~3049 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb7e1a6f0c0b39cef4a1496d2992b55bd5e08395;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Do not use CorHost2::m_fStarted to gate execution (dotnet/coreclr#20953) * ExecuteInDefaultAppDomain w/o Start Do not require Start() call before calling ExecuteInDefaultAppDomain() * Remove unused variable * Move flags as needed to CorHost2 Commit migrated from https://github.com/dotnet/coreclr/commit/f6d403292c17f7024509c59593bcab05ee9379f1 --- diff --git a/src/coreclr/src/inc/corhost.h b/src/coreclr/src/inc/corhost.h index 002f508..62fd7e4 100644 --- a/src/coreclr/src/inc/corhost.h +++ b/src/coreclr/src/inc/corhost.h @@ -62,7 +62,6 @@ protected: CorRuntimeHostBase() :m_Started(FALSE), m_cRef(0) - , m_fStarted(FALSE) {LIMITED_METHOD_CONTRACT;} STDMETHODIMP_(ULONG) AddRef(void); @@ -125,10 +124,6 @@ protected: LONG m_cRef; // Ref count. - // This flag will be used to ensure that a CoreCLR host can invoke Start/Stop in pairs only. - BOOL m_fStarted; - BOOL m_fAppDomainCreated; // this flag is used when an appdomain can only create a single appdomain - static ULONG m_Version; // Version of ICorRuntimeHost. // Some functions are only available in ICLRRuntimeHost. // Some functions are no-op in ICLRRuntimeHost. @@ -365,9 +360,9 @@ private: // This flag indicates if this instance was the first to load and start CoreCLR BOOL m_fFirstToLoadCLR; - // This flag indicates if the host has authenticated with us or not - BOOL m_fIsHostAuthenticated; - + // This flag will be used to ensure that a CoreCLR host can invoke Start/Stop in pairs only. + BOOL m_fStarted; + BOOL m_fAppDomainCreated; // this flag is used when an appdomain can only create a single appdomain // Helpers for both ICLRRuntimeHost2 and ICLRPrivRuntime HRESULT _CreateAppDomain( diff --git a/src/coreclr/src/vm/corhost.cpp b/src/coreclr/src/vm/corhost.cpp index a097520..d2859cc 100644 --- a/src/coreclr/src/vm/corhost.cpp +++ b/src/coreclr/src/vm/corhost.cpp @@ -104,13 +104,9 @@ typedef DPTR(CONNID) PTR_CONNID; // *** ICorRuntimeHost methods *** -CorHost2::CorHost2() +CorHost2::CorHost2() : m_fFirstToLoadCLR(FALSE), m_fStarted(FALSE), m_fAppDomainCreated(FALSE) { LIMITED_METHOD_CONTRACT; - - m_fStarted = FALSE; - m_fFirstToLoadCLR = FALSE; - m_fAppDomainCreated = FALSE; } static DangerousNonHostedSpinLock lockOnlyOneToInvokeStart; @@ -298,9 +294,7 @@ HRESULT CorHost2::GetCurrentAppDomainId(DWORD *pdwAppDomainId) // No point going further if the runtime is not running... // We use CanRunManagedCode() instead of IsRuntimeActive() because this allows us // to specify test using the form that does not trigger a GC. - if (!(g_fEEStarted && CanRunManagedCode(LoaderLockCheck::None)) - || !m_fStarted - ) + if (!(g_fEEStarted && CanRunManagedCode(LoaderLockCheck::None))) { return HOST_E_CLRNOTAVAILABLE; } @@ -417,7 +411,7 @@ HRESULT CorHost2::ExecuteAssembly(DWORD dwAppDomainId, return HOST_E_INVALIDOPERATION; // No point going further if the runtime is not running... - if (!IsRuntimeActive() || !m_fStarted) + if (!IsRuntimeActive()) { return HOST_E_CLRNOTAVAILABLE; } @@ -513,9 +507,7 @@ HRESULT CorHost2::ExecuteInDefaultAppDomain(LPCWSTR pwzAssemblyPath, CONTRACTL_END; // No point going further if the runtime is not running... - if (!IsRuntimeActive() - || !m_fStarted - ) + if (!IsRuntimeActive()) { return HOST_E_CLRNOTAVAILABLE; } @@ -622,9 +614,7 @@ HRESULT CorHost2::ExecuteInAppDomain(DWORD dwAppDomainId, { // No point going further if the runtime is not running... - if (!IsRuntimeActive() - || !m_fStarted - ) + if (!IsRuntimeActive()) { return HOST_E_CLRNOTAVAILABLE; } @@ -851,9 +841,6 @@ HRESULT CorHost2::_CreateDelegate( if(wszMethodName == NULL) return E_INVALIDARG; - if (!m_fStarted) - return HOST_E_INVALIDOPERATION; - BEGIN_ENTRYPOINT_NOTHROW; BEGIN_EXTERNAL_ENTRYPOINT(&hr); @@ -1241,7 +1228,6 @@ STDMETHODIMP CorHost2::UnloadAppDomain2(DWORD dwDomainId, BOOL fWaitUntilDone, i if (1 == refCount) { // Stop coreclr on unload. - m_fStarted = FALSE; EEShutDown(FALSE); } else diff --git a/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp b/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp index 597c248..676087b 100644 --- a/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp +++ b/src/coreclr/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp @@ -53,12 +53,9 @@ CallExecuteInDefaultAppDomain(LPCWSTR pwzAssemblyPath, if (!host) return E_FAIL; - if(host->Start()) - return E_FAIL; - auto result = host->ExecuteInDefaultAppDomain(pwzAssemblyPath, pwzTypeName, pwzMethodName, pwzArgument, pReturnValue); - host->Stop(); + host->Release(); return result; }