mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-30 10:34:21 +01:00
Merge pull request #2761 from yuriks/session-references
Kernel: Ensure objects are kept alive during ClientSession disconnection
This commit is contained in:
commit
3146e95585
@ -18,7 +18,6 @@ class WaitObject;
|
|||||||
class Event;
|
class Event;
|
||||||
class Mutex;
|
class Mutex;
|
||||||
class Semaphore;
|
class Semaphore;
|
||||||
class Session;
|
|
||||||
class Thread;
|
class Thread;
|
||||||
class Timer;
|
class Timer;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "core/hle/kernel/errors.h"
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/hle_ipc.h"
|
#include "core/hle/kernel/hle_ipc.h"
|
||||||
#include "core/hle/kernel/server_session.h"
|
#include "core/hle/kernel/server_session.h"
|
||||||
|
#include "core/hle/kernel/session.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
@ -16,9 +17,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 +33,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
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/session.h"
|
|
||||||
#include "core/hle/kernel/wait_object.h"
|
#include "core/hle/kernel/wait_object.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
@ -19,6 +18,7 @@ namespace Kernel {
|
|||||||
class ClientSession;
|
class ClientSession;
|
||||||
class ClientPort;
|
class ClientPort;
|
||||||
class ServerSession;
|
class ServerSession;
|
||||||
|
class Session;
|
||||||
class SessionRequestHandler;
|
class SessionRequestHandler;
|
||||||
class Thread;
|
class Thread;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user