Kernel: Ensure objects are kept alive during ClientSession disconnection
Fixes #2760
This commit is contained in:
parent
8c22334f96
commit
d666e01cdf
1 changed files with 13 additions and 7 deletions
|
@ -16,9 +16,13 @@ ClientSession::~ClientSession() {
|
||||||
// This destructor will be called automatically when the last ClientSession handle is closed by
|
// This destructor will be called automatically when the last ClientSession handle is closed by
|
||||||
// the emulated application.
|
// the emulated application.
|
||||||
|
|
||||||
if (parent->server) {
|
// Local references to ServerSession and SessionRequestHandler are necessary to guarantee they
|
||||||
if (parent->server->hle_handler)
|
// will be kept alive until after ClientDisconnected() returns.
|
||||||
parent->server->hle_handler->ClientDisconnected(parent->server);
|
SharedPtr<ServerSession> server = parent->server;
|
||||||
|
if (server) {
|
||||||
|
std::shared_ptr<SessionRequestHandler> hle_handler = server->hle_handler;
|
||||||
|
if (hle_handler)
|
||||||
|
hle_handler->ClientDisconnected(server);
|
||||||
|
|
||||||
// TODO(Subv): Force a wake up of all the ServerSession's waiting threads and set
|
// TODO(Subv): Force a wake up of all the ServerSession's waiting threads and set
|
||||||
// their WaitSynchronization result to 0xC920181A.
|
// their WaitSynchronization result to 0xC920181A.
|
||||||
|
@ -28,11 +32,13 @@ ClientSession::~ClientSession() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultCode ClientSession::SendSyncRequest() {
|
ResultCode ClientSession::SendSyncRequest() {
|
||||||
// Signal the server session that new data is available
|
// Keep ServerSession alive until we're done working with it.
|
||||||
if (parent->server)
|
SharedPtr<ServerSession> server = parent->server;
|
||||||
return parent->server->HandleSyncRequest();
|
if (server == nullptr)
|
||||||
|
return ERR_SESSION_CLOSED_BY_REMOTE;
|
||||||
|
|
||||||
return ERR_SESSION_CLOSED_BY_REMOTE;
|
// Signal the server session that new data is available
|
||||||
|
return server->HandleSyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in a new issue