Fixed incorrect content manager destruction

This commit is contained in:
Adubbz 2019-08-04 23:39:54 +10:00
parent 9e9987a673
commit f080f6793b
9 changed files with 38 additions and 7 deletions

View file

@ -257,6 +257,8 @@ namespace sts::ncm::impl {
} }
void FinalizeContentManager() { void FinalizeContentManager() {
debug::DebugLog("Finalizing content manager...\n");
{ {
std::scoped_lock<HosMutex> lk(g_mutex); std::scoped_lock<HosMutex> lk(g_mutex);

View file

@ -66,6 +66,7 @@ namespace sts::ncm::impl {
this->EnsureRecursively(placeholder_id); this->EnsureRecursively(placeholder_id);
this->GetPlaceHolderPathUncached(placeholder_path, placeholder_id); this->GetPlaceHolderPathUncached(placeholder_path, placeholder_id);
debug::DebugLog("Creating %s\n", placeholder_path);
R_TRY_CATCH(fsdevCreateFile(placeholder_path, size, FS_CREATE_BIG_FILE)) { R_TRY_CATCH(fsdevCreateFile(placeholder_path, size, FS_CREATE_BIG_FILE)) {
R_CATCH(ResultFsPathAlreadyExists) { R_CATCH(ResultFsPathAlreadyExists) {
return ResultNcmPlaceHolderAlreadyExists; return ResultNcmPlaceHolderAlreadyExists;
@ -80,6 +81,7 @@ namespace sts::ncm::impl {
this->GetPlaceHolderPathUncached(placeholder_path, placeholder_id); this->GetPlaceHolderPathUncached(placeholder_path, placeholder_id);
debug::DebugLog("Deleting %s\n", placeholder_path);
if (std::remove(placeholder_path) != 0) { if (std::remove(placeholder_path) != 0) {
R_TRY_CATCH(fsdevGetLastResult()) { R_TRY_CATCH(fsdevGetLastResult()) {
R_CATCH(ResultFsPathNotFound) { R_CATCH(ResultFsPathNotFound) {

View file

@ -17,6 +17,8 @@
#include "impl/ncm_content_manager.hpp" #include "impl/ncm_content_manager.hpp"
#include "lr_addoncontentlocationresolver.hpp" #include "lr_addoncontentlocationresolver.hpp"
#include "debug.hpp"
namespace sts::lr { namespace sts::lr {
AddOnContentLocationResolverInterface::AddOnContentLocationResolverInterface() { AddOnContentLocationResolverInterface::AddOnContentLocationResolverInterface() {
@ -24,6 +26,7 @@ namespace sts::lr {
} }
Result AddOnContentLocationResolverInterface::ResolveAddOnContentPath(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) { Result AddOnContentLocationResolverInterface::ResolveAddOnContentPath(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) {
R_DEBUG_START
Path path; Path path;
ncm::StorageId storage_id = ncm::StorageId::None; ncm::StorageId storage_id = ncm::StorageId::None;
@ -42,16 +45,21 @@ namespace sts::lr {
*out.pointer = path; *out.pointer = path;
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result AddOnContentLocationResolverInterface::RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::TitleId tid) { Result AddOnContentLocationResolverInterface::RegisterAddOnContentStorage(ncm::StorageId storage_id, ncm::TitleId tid) {
R_DEBUG_START
R_TRY(this->redirector.SetRedirection(tid, storage_id)); R_TRY(this->redirector.SetRedirection(tid, storage_id));
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result AddOnContentLocationResolverInterface::UnregisterAllAddOnContentPath() { Result AddOnContentLocationResolverInterface::UnregisterAllAddOnContentPath() {
R_DEBUG_START
this->redirector.ClearRedirections(); this->redirector.ClearRedirections();
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
} }

View file

@ -48,6 +48,7 @@ namespace sts::lr {
R_ASSERT(this->content_storage->GetPath(&path, program_content_id)); R_ASSERT(this->content_storage->GetPath(&path, program_content_id));
*out.pointer = path; *out.pointer = path;
debug::DebugLog("Resolved program path to %s\n", path.path);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END R_DEBUG_END
} }
@ -107,6 +108,7 @@ namespace sts::lr {
Result ContentLocationResolverInterface::RedirectApplicationHtmlDocumentPath(InPointer<const Path> path, ncm::TitleId tid) { Result ContentLocationResolverInterface::RedirectApplicationHtmlDocumentPath(InPointer<const Path> path, ncm::TitleId tid) {
R_DEBUG_START R_DEBUG_START
this->html_docs_redirector.SetRedirection(tid, *path.pointer, impl::RedirectionFlags_Application); this->html_docs_redirector.SetRedirection(tid, *path.pointer, impl::RedirectionFlags_Application);
debug::DebugLog("Redirected application html document path to %s\n", (*path.pointer).path);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END R_DEBUG_END
} }

View file

@ -152,21 +152,28 @@ namespace sts::lr {
} }
Result RedirectOnlyLocationResolverInterface::EraseApplicationControlRedirection(ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::EraseApplicationControlRedirection(ncm::TitleId tid) {
R_DEBUG_START
this->app_control_redirector.EraseRedirection(tid); this->app_control_redirector.EraseRedirection(tid);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result RedirectOnlyLocationResolverInterface::EraseApplicationHtmlDocumentRedirection(ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::EraseApplicationHtmlDocumentRedirection(ncm::TitleId tid) {
R_DEBUG_START
this->html_docs_redirector.EraseRedirection(tid); this->html_docs_redirector.EraseRedirection(tid);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result RedirectOnlyLocationResolverInterface::EraseApplicationLegalInformationRedirection(ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::EraseApplicationLegalInformationRedirection(ncm::TitleId tid) {
R_DEBUG_START
this->legal_info_redirector.EraseRedirection(tid); this->legal_info_redirector.EraseRedirection(tid);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result RedirectOnlyLocationResolverInterface::ResolveProgramPathForDebug(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::ResolveProgramPathForDebug(OutPointerWithServerSize<Path, 0x1> out, ncm::TitleId tid) {
R_DEBUG_START
Path path; Path path;
if (this->debug_program_redirector.FindRedirection(&path, tid)) { if (this->debug_program_redirector.FindRedirection(&path, tid)) {
@ -182,21 +189,28 @@ namespace sts::lr {
*out.pointer = path; *out.pointer = path;
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result RedirectOnlyLocationResolverInterface::RedirectProgramPathForDebug(InPointer<const Path> path, ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::RedirectProgramPathForDebug(InPointer<const Path> path, ncm::TitleId tid) {
R_DEBUG_START
this->debug_program_redirector.SetRedirection(tid, *path.pointer); this->debug_program_redirector.SetRedirection(tid, *path.pointer);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result RedirectOnlyLocationResolverInterface::RedirectApplicationProgramPathForDebug(InPointer<const Path> path, ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::RedirectApplicationProgramPathForDebug(InPointer<const Path> path, ncm::TitleId tid) {
R_DEBUG_START
this->debug_program_redirector.SetRedirection(tid, *path.pointer, impl::RedirectionFlags_Application); this->debug_program_redirector.SetRedirection(tid, *path.pointer, impl::RedirectionFlags_Application);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result RedirectOnlyLocationResolverInterface::EraseProgramRedirectionForDebug(ncm::TitleId tid) { Result RedirectOnlyLocationResolverInterface::EraseProgramRedirectionForDebug(ncm::TitleId tid) {
R_DEBUG_START
this->debug_program_redirector.EraseRedirection(tid); this->debug_program_redirector.EraseRedirection(tid);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
} }

View file

@ -21,10 +21,6 @@
namespace sts::ncm { namespace sts::ncm {
ContentManagerService::~ContentManagerService() {
impl::FinalizeContentManager();
}
Result ContentManagerService::CreateContentStorage(StorageId storage_id) { Result ContentManagerService::CreateContentStorage(StorageId storage_id) {
R_DEBUG_START R_DEBUG_START
return impl::CreateContentStorage(storage_id); return impl::CreateContentStorage(storage_id);

View file

@ -40,8 +40,6 @@ namespace sts::ncm {
ActivateContentMetaDatabase = 11, ActivateContentMetaDatabase = 11,
InactivateContentMetaDatabase = 12, InactivateContentMetaDatabase = 12,
}; };
public:
~ContentManagerService();
public: public:
virtual Result CreateContentStorage(StorageId storage_id); virtual Result CreateContentStorage(StorageId storage_id);
virtual Result CreateContentMetaDatabase(StorageId storage_id); virtual Result CreateContentMetaDatabase(StorageId storage_id);

View file

@ -209,10 +209,12 @@ namespace sts::ncm {
} }
Result ContentMetaDatabaseInterface::GetContentIdByType(Out<ContentId> out_content_id, ContentMetaKey key, ContentType type) { Result ContentMetaDatabaseInterface::GetContentIdByType(Out<ContentId> out_content_id, ContentMetaKey key, ContentType type) {
R_DEBUG_START
ContentId content_id; ContentId content_id;
R_TRY(this->GetContentIdByTypeImpl(&content_id, key, type, std::nullopt)); R_TRY(this->GetContentIdByTypeImpl(&content_id, key, type, std::nullopt));
out_content_id.SetValue(content_id); out_content_id.SetValue(content_id);
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
Result ContentMetaDatabaseInterface::ListContentInfo(Out<u32> out_count, OutBuffer<ContentInfo> out_info, ContentMetaKey key, u32 offset) { Result ContentMetaDatabaseInterface::ListContentInfo(Out<u32> out_count, OutBuffer<ContentInfo> out_info, ContentMetaKey key, u32 offset) {
@ -664,13 +666,16 @@ namespace sts::ncm {
} }
Result OnMemoryContentMetaDatabaseInterface::LookupOrphanContent(OutBuffer<bool> out_orphaned, InBuffer<ContentId> content_ids) { Result OnMemoryContentMetaDatabaseInterface::LookupOrphanContent(OutBuffer<bool> out_orphaned, InBuffer<ContentId> content_ids) {
R_DEBUG_START
return ResultNcmInvalidContentMetaDatabase; return ResultNcmInvalidContentMetaDatabase;
R_DEBUG_END
} }
Result OnMemoryContentMetaDatabaseInterface::Commit() { Result OnMemoryContentMetaDatabaseInterface::Commit() {
R_DEBUG_START
R_TRY(this->EnsureEnabled()); R_TRY(this->EnsureEnabled());
return ResultSuccess; return ResultSuccess;
R_DEBUG_END
} }
} }

View file

@ -22,6 +22,8 @@
#include "lr_manager_service.hpp" #include "lr_manager_service.hpp"
#include "ncm_content_manager_service.hpp" #include "ncm_content_manager_service.hpp"
#include "debug.hpp"
extern "C" { extern "C" {
extern u32 __start__; extern u32 __start__;
@ -161,5 +163,7 @@ int main(int argc, char **argv)
s_content_manager_thread.Join(); s_content_manager_thread.Join();
s_location_resolver_thread.Join(); s_location_resolver_thread.Join();
sts::ncm::impl::FinalizeContentManager();
return 0; return 0;
} }