mirror of
https://github.com/microsoft/WSL.git
synced 2025-12-11 04:35:57 -06:00
Merge upstream WSLA changes and restore session ID support
This commit is contained in:
parent
b46de5880d
commit
692faed78e
@ -8,7 +8,7 @@ Module Name:
|
||||
|
||||
Abstract:
|
||||
|
||||
TODO
|
||||
Entry point for the wsladiag tool, performs WSL runtime initialization and parses --list/--help.
|
||||
|
||||
--*/
|
||||
|
||||
|
||||
@ -24,10 +24,7 @@ using wsl::windows::service::wsla::WSLAVirtualMachine;
|
||||
|
||||
WSLASession::WSLASession(ULONG id, const WSLA_SESSION_SETTINGS& Settings, WSLAUserSessionImpl& userSessionImpl) :
|
||||
|
||||
m_id(id),
|
||||
m_sessionSettings(Settings),
|
||||
m_userSession(&userSessionImpl),
|
||||
m_displayName(Settings.DisplayName)
|
||||
m_id(id), m_sessionSettings(Settings), m_userSession(&userSessionImpl), m_displayName(Settings.DisplayName)
|
||||
{
|
||||
WSL_LOG("SessionCreated", TraceLoggingValue(m_displayName.c_str(), "DisplayName"));
|
||||
|
||||
@ -185,12 +182,6 @@ void WSLASession::ConfigureStorage(const WSLA_SESSION_SETTINGS& Settings)
|
||||
deleteVhdOnFailure.release();
|
||||
}
|
||||
|
||||
HRESULT WSLASession::GetDisplayName(LPWSTR* DisplayName)
|
||||
{
|
||||
RETURN_HR_IF_NULL(E_POINTER, DisplayName);
|
||||
return wil::make_cotaskmem_string_nothrow(m_displayName.c_str(), DisplayName);
|
||||
}
|
||||
|
||||
void WSLASession::CopyDisplayName(_Out_writes_z_(bufferLength) PWSTR buffer, size_t bufferLength) const
|
||||
{
|
||||
THROW_HR_IF(E_BOUNDS, m_displayName.size() + 1 > bufferLength);
|
||||
|
||||
@ -27,7 +27,7 @@ WSLAUserSessionImpl::~WSLAUserSessionImpl()
|
||||
// In case there are still COM references on sessions, signal that the user session is terminating
|
||||
// so the sessions are all in a 'terminated' state.
|
||||
{
|
||||
std::lock_guard lock(m_lock);
|
||||
std::lock_guard lock(m_wslaSessionsLock);
|
||||
|
||||
for (auto& e : m_sessions)
|
||||
{
|
||||
@ -38,7 +38,7 @@ WSLAUserSessionImpl::~WSLAUserSessionImpl()
|
||||
|
||||
void WSLAUserSessionImpl::OnSessionTerminated(WSLASession* Session)
|
||||
{
|
||||
std::lock_guard lock(m_lock);
|
||||
std::lock_guard lock(m_wslaSessionsLock);
|
||||
WI_VERIFY(m_sessions.erase(Session) == 1);
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ HRESULT WSLAUserSessionImpl::CreateSession(const WSLA_SESSION_SETTINGS* Settings
|
||||
{
|
||||
ULONG id = m_nextSessionId++;
|
||||
auto session = wil::MakeOrThrow<WSLASession>(id, *Settings, *this);
|
||||
|
||||
|
||||
std::lock_guard lock(m_wslaSessionsLock);
|
||||
auto it = m_sessions.emplace(session.Get());
|
||||
|
||||
@ -65,7 +65,7 @@ HRESULT WSLAUserSessionImpl::CreateSession(const WSLA_SESSION_SETTINGS* Settings
|
||||
|
||||
HRESULT WSLAUserSessionImpl::OpenSessionByName(LPCWSTR DisplayName, IWSLASession** Session)
|
||||
{
|
||||
std::lock_guard lock(m_lock);
|
||||
std::lock_guard lock(m_wslaSessionsLock);
|
||||
|
||||
// TODO: ACL check
|
||||
// TODO: Check for duplicate on session creation.
|
||||
@ -83,7 +83,7 @@ HRESULT WSLAUserSessionImpl::OpenSessionByName(LPCWSTR DisplayName, IWSLASession
|
||||
|
||||
HRESULT wsl::windows::service::wsla::WSLAUserSessionImpl::ListSessions(_Out_ WSLA_SESSION_INFORMATION** Sessions, _Out_ ULONG* SessionsCount)
|
||||
{
|
||||
std::lock_guard lock(m_lock);
|
||||
std::lock_guard lock(m_wslaSessionsLock);
|
||||
auto output = wil::make_unique_cotaskmem<WSLA_SESSION_INFORMATION[]>(m_sessions.size());
|
||||
|
||||
size_t index = 0;
|
||||
|
||||
@ -43,7 +43,7 @@ private:
|
||||
wil::unique_tokeninfo_ptr<TOKEN_USER> m_tokenInfo;
|
||||
|
||||
std::atomic<ULONG> m_nextSessionId{1};
|
||||
std::recursive_mutex m_lock;
|
||||
std::recursive_mutex m_wslaSessionsLock;
|
||||
|
||||
// TODO-WSLA: Consider using a weak_ptr to easily destroy when the last client reference is released.
|
||||
std::unordered_set<WSLASession*> m_sessions;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user