client_session.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/hle/kernel/client_session.h"
  5. #include "core/hle/kernel/errors.h"
  6. #include "core/hle/kernel/hle_ipc.h"
  7. #include "core/hle/kernel/server_session.h"
  8. #include "core/hle/kernel/session.h"
  9. #include "core/hle/kernel/thread.h"
  10. namespace Kernel {
  11. ClientSession::ClientSession(KernelCore& kernel) : Object{kernel} {}
  12. ClientSession::~ClientSession() {
  13. // This destructor will be called automatically when the last ClientSession handle is closed by
  14. // the emulated application.
  15. // Local references to ServerSession and SessionRequestHandler are necessary to guarantee they
  16. // will be kept alive until after ClientDisconnected() returns.
  17. SharedPtr<ServerSession> server = parent->server;
  18. if (server) {
  19. std::shared_ptr<SessionRequestHandler> hle_handler = server->hle_handler;
  20. if (hle_handler)
  21. hle_handler->ClientDisconnected(server);
  22. // TODO(Subv): Force a wake up of all the ServerSession's waiting threads and set
  23. // their WaitSynchronization result to 0xC920181A.
  24. // Clean up the list of client threads with pending requests, they are unneeded now that the
  25. // client endpoint is closed.
  26. server->pending_requesting_threads.clear();
  27. server->currently_handling = nullptr;
  28. }
  29. parent->client = nullptr;
  30. }
  31. ResultCode ClientSession::SendSyncRequest(SharedPtr<Thread> thread) {
  32. // Keep ServerSession alive until we're done working with it.
  33. SharedPtr<ServerSession> server = parent->server;
  34. if (server == nullptr)
  35. return ERR_SESSION_CLOSED_BY_REMOTE;
  36. // Signal the server session that new data is available
  37. return server->HandleSyncRequest(std::move(thread));
  38. }
  39. } // namespace Kernel