diff options
Diffstat (limited to 'src/core/hle/service/bcat')
-rw-r--r-- | src/core/hle/service/bcat/backend/backend.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/bcat/backend/boxcat.cpp | 22 | ||||
-rw-r--r-- | src/core/hle/service/bcat/module.cpp | 41 | ||||
-rw-r--r-- | src/core/hle/service/bcat/module.h | 3 |
4 files changed, 40 insertions, 28 deletions
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index def3410cc..174388445 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp @@ -84,7 +84,7 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) { void ProgressServiceBackend::SignalUpdate() const { if (need_hle_lock) { - std::lock_guard<std::recursive_mutex> lock(HLE::g_hle_lock); + std::lock_guard lock(HLE::g_hle_lock); event.writable->Signal(); } else { event.writable->Signal(); diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index ca021a99f..e43f3f47f 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -196,7 +196,9 @@ private: const std::string& content_type_name) { if (client == nullptr) { client = std::make_unique<httplib::SSLClient>(BOXCAT_HOSTNAME, PORT); - client->set_timeout_sec(timeout_seconds); + client->set_connection_timeout(timeout_seconds); + client->set_read_timeout(timeout_seconds); + client->set_write_timeout(timeout_seconds); } httplib::Headers headers{ @@ -255,7 +257,7 @@ private: return out; } - std::unique_ptr<httplib::Client> client; + std::unique_ptr<httplib::SSLClient> client; std::string path; u64 title_id; u64 build_id; @@ -443,13 +445,25 @@ std::optional<std::vector<u8>> Boxcat::GetLaunchParameter(TitleIDVersion title) Boxcat::StatusResult Boxcat::GetStatus(std::optional<std::string>& global, std::map<std::string, EventStatus>& games) { httplib::SSLClient client{BOXCAT_HOSTNAME, static_cast<int>(PORT)}; - client.set_timeout_sec(static_cast<int>(TIMEOUT_SECONDS)); + client.set_connection_timeout(static_cast<int>(TIMEOUT_SECONDS)); + client.set_read_timeout(static_cast<int>(TIMEOUT_SECONDS)); + client.set_write_timeout(static_cast<int>(TIMEOUT_SECONDS)); httplib::Headers headers{ {std::string("Game-Assets-API-Version"), std::string(BOXCAT_API_VERSION)}, {std::string("Boxcat-Client-Type"), std::string(BOXCAT_CLIENT_TYPE)}, }; + if (!client.is_valid()) { + LOG_ERROR(Service_BCAT, "Client is invalid, going offline!"); + return StatusResult::Offline; + } + + if (!client.is_socket_open()) { + LOG_ERROR(Service_BCAT, "Failed to open socket, going offline!"); + return StatusResult::Offline; + } + const auto response = client.Get(BOXCAT_PATHNAME_EVENTS, headers); if (response == nullptr) return StatusResult::Offline; @@ -469,7 +483,7 @@ Boxcat::StatusResult Boxcat::GetStatus(std::optional<std::string>& global, global = json["global"].get<std::string>(); if (json["games"].is_array()) { - for (const auto object : json["games"]) { + for (const auto& object : json["games"]) { if (object.is_object() && object.find("name") != object.end()) { EventStatus detail{}; if (object["header"].is_string()) { diff --git a/src/core/hle/service/bcat/module.cpp b/src/core/hle/service/bcat/module.cpp index db0e06ca1..b8696a395 100644 --- a/src/core/hle/service/bcat/module.cpp +++ b/src/core/hle/service/bcat/module.cpp @@ -8,6 +8,7 @@ #include "common/hex_util.h" #include "common/logging/log.h" #include "common/string_util.h" +#include "core/core.h" #include "core/file_sys/vfs.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/process.h" @@ -87,9 +88,11 @@ struct DeliveryCacheDirectoryEntry { class IDeliveryCacheProgressService final : public ServiceFramework<IDeliveryCacheProgressService> { public: - IDeliveryCacheProgressService(std::shared_ptr<Kernel::ReadableEvent> event, - const DeliveryCacheProgressImpl& impl) - : ServiceFramework{"IDeliveryCacheProgressService"}, event(std::move(event)), impl(impl) { + explicit IDeliveryCacheProgressService(Core::System& system_, + std::shared_ptr<Kernel::ReadableEvent> event_, + const DeliveryCacheProgressImpl& impl_) + : ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{std::move(event_)}, + impl{impl_} { // clang-format off static const FunctionInfo functions[] = { {0, &IDeliveryCacheProgressService::GetEvent, "GetEvent"}, @@ -125,7 +128,7 @@ private: class IBcatService final : public ServiceFramework<IBcatService> { public: explicit IBcatService(Core::System& system_, Backend& backend_) - : ServiceFramework("IBcatService"), system{system_}, backend{backend_}, + : ServiceFramework{system_, "IBcatService"}, backend{backend_}, progress{{ ProgressServiceBackend{system_.Kernel(), "Normal"}, ProgressServiceBackend{system_.Kernel(), "Directory"}, @@ -170,7 +173,7 @@ private: std::shared_ptr<IDeliveryCacheProgressService> CreateProgressService(SyncType type) { auto& backend{progress.at(static_cast<std::size_t>(type))}; - return std::make_shared<IDeliveryCacheProgressService>(backend.GetEvent(), + return std::make_shared<IDeliveryCacheProgressService>(system, backend.GetEvent(), backend.GetImpl()); } @@ -260,7 +263,6 @@ private: rb.Push(RESULT_SUCCESS); } - Core::System& system; Backend& backend; std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress; @@ -276,8 +278,8 @@ void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) { class IDeliveryCacheFileService final : public ServiceFramework<IDeliveryCacheFileService> { public: - IDeliveryCacheFileService(FileSys::VirtualDir root_) - : ServiceFramework{"IDeliveryCacheFileService"}, root(std::move(root_)) { + explicit IDeliveryCacheFileService(Core::System& system_, FileSys::VirtualDir root_) + : ServiceFramework{system_, "IDeliveryCacheFileService"}, root(std::move(root_)) { // clang-format off static const FunctionInfo functions[] = { {0, &IDeliveryCacheFileService::Open, "Open"}, @@ -393,8 +395,8 @@ private: class IDeliveryCacheDirectoryService final : public ServiceFramework<IDeliveryCacheDirectoryService> { public: - IDeliveryCacheDirectoryService(FileSys::VirtualDir root_) - : ServiceFramework{"IDeliveryCacheDirectoryService"}, root(std::move(root_)) { + explicit IDeliveryCacheDirectoryService(Core::System& system_, FileSys::VirtualDir root_) + : ServiceFramework{system_, "IDeliveryCacheDirectoryService"}, root(std::move(root_)) { // clang-format off static const FunctionInfo functions[] = { {0, &IDeliveryCacheDirectoryService::Open, "Open"}, @@ -491,8 +493,8 @@ private: class IDeliveryCacheStorageService final : public ServiceFramework<IDeliveryCacheStorageService> { public: - IDeliveryCacheStorageService(FileSys::VirtualDir root_) - : ServiceFramework{"IDeliveryCacheStorageService"}, root(std::move(root_)) { + explicit IDeliveryCacheStorageService(Core::System& system_, FileSys::VirtualDir root_) + : ServiceFramework{system_, "IDeliveryCacheStorageService"}, root(std::move(root_)) { // clang-format off static const FunctionInfo functions[] = { {0, &IDeliveryCacheStorageService::CreateFileService, "CreateFileService"}, @@ -517,7 +519,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IDeliveryCacheFileService>(root); + rb.PushIpcInterface<IDeliveryCacheFileService>(system, root); } void CreateDirectoryService(Kernel::HLERequestContext& ctx) { @@ -525,7 +527,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IDeliveryCacheDirectoryService>(root); + rb.PushIpcInterface<IDeliveryCacheDirectoryService>(system, root); } void EnumerateDeliveryCacheDirectory(Kernel::HLERequestContext& ctx) { @@ -550,10 +552,10 @@ private: void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_BCAT, "called"); + const auto title_id = system.CurrentProcess()->GetTitleID(); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IDeliveryCacheStorageService>( - fsc.GetBCATDirectory(system.CurrentProcess()->GetTitleID())); + rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id)); } void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId( @@ -565,7 +567,7 @@ void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId( IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(RESULT_SUCCESS); - rb.PushIpcInterface<IDeliveryCacheStorageService>(fsc.GetBCATDirectory(title_id)); + rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id)); } std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system, @@ -581,10 +583,9 @@ std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_, FileSystem::FileSystemController& fsc_, const char* name) - : ServiceFramework(name), fsc{fsc_}, module{std::move(module_)}, + : ServiceFramework{system_, name}, fsc{fsc_}, module{std::move(module_)}, backend{CreateBackendFromSettings(system_, - [&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })}, - system{system_} {} + [&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })} {} Module::Interface::~Interface() = default; diff --git a/src/core/hle/service/bcat/module.h b/src/core/hle/service/bcat/module.h index e4ba23ba0..738731c06 100644 --- a/src/core/hle/service/bcat/module.h +++ b/src/core/hle/service/bcat/module.h @@ -37,9 +37,6 @@ public: std::shared_ptr<Module> module; std::unique_ptr<Backend> backend; - - private: - Core::System& system; }; }; |