client_session.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #include "core/hle/result.h"
  11. namespace Kernel {
  12. ClientSession::ClientSession(KernelCore& kernel) : Object{kernel} {}
  13. ClientSession::~ClientSession() {
  14. // This destructor will be called automatically when the last ClientSession handle is closed by
  15. // the emulated application.
  16. // Local references to ServerSession and SessionRequestHandler are necessary to guarantee they
  17. // will be kept alive until after ClientDisconnected() returns.
  18. SharedPtr<ServerSession> server = parent->server;
  19. if (server) {
  20. std::shared_ptr<SessionRequestHandler> hle_handler = server->hle_handler;
  21. if (hle_handler)
  22. hle_handler->ClientDisconnected(server);
  23. // TODO(Subv): Force a wake up of all the ServerSession's waiting threads and set
  24. // their WaitSynchronization result to 0xC920181A.
  25. // Clean up the list of client threads with pending requests, they are unneeded now that the
  26. // client endpoint is closed.
  27. server->pending_requesting_threads.clear();
  28. server->currently_handling = nullptr;
  29. }
  30. parent->client = nullptr;
  31. }
  32. ResultCode ClientSession::SendSyncRequest(SharedPtr<Thread> thread) {
  33. // Keep ServerSession alive until we're done working with it.
  34. SharedPtr<ServerSession> server = parent->server;
  35. if (server == nullptr)
  36. return ERR_SESSION_CLOSED_BY_REMOTE;
  37. // Signal the server session that new data is available
  38. return server->HandleSyncRequest(std::move(thread));
  39. }
  40. } // namespace Kernel