From a416d94e38f5417649304d4d01d568e0774b742d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Dec 2023 12:17:10 +0100 Subject: [PATCH] CHD over http wasn't actually working, disable again until it can be fixed --- Common/LogManager.cpp | 4 +++- Common/Net/Sinks.cpp | 2 +- Common/Net/Sinks.h | 2 +- Core/FileLoaders/DiskCachingFileLoader.cpp | 2 +- Core/FileSystems/BlockDevices.cpp | 6 +++++- Core/FileSystems/BlockDevices.h | 8 ++++---- Core/System.cpp | 6 ++++++ Core/WebServer.cpp | 4 +++- 8 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 60396a6e275e..d7fac46d39ea 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -302,7 +302,9 @@ void LogManager::RemoveListener(LogListener *listener) { } FileLogListener::FileLogListener(const char *filename) { - fp_ = File::OpenCFile(Path(std::string(filename)), "at"); + if (strlen(filename) > 0) { + fp_ = File::OpenCFile(Path(std::string(filename)), "at"); + } SetEnabled(fp_ != nullptr); } diff --git a/Common/Net/Sinks.cpp b/Common/Net/Sinks.cpp index b6453bcf85f6..62eb407daca1 100644 --- a/Common/Net/Sinks.cpp +++ b/Common/Net/Sinks.cpp @@ -422,7 +422,7 @@ bool OutputSink::Empty() const { return valid_ == 0; } -int OutputSink::BytesRemaining() const { +size_t OutputSink::BytesRemaining() const { return valid_; } diff --git a/Common/Net/Sinks.h b/Common/Net/Sinks.h index b997abf34203..b42c441eb76a 100644 --- a/Common/Net/Sinks.h +++ b/Common/Net/Sinks.h @@ -55,7 +55,7 @@ class OutputSink { void Discard(); bool Empty() const; - int BytesRemaining() const; + size_t BytesRemaining() const; private: void Drain(); diff --git a/Core/FileLoaders/DiskCachingFileLoader.cpp b/Core/FileLoaders/DiskCachingFileLoader.cpp index 9ee0fcabf606..dee0d5a70af5 100644 --- a/Core/FileLoaders/DiskCachingFileLoader.cpp +++ b/Core/FileLoaders/DiskCachingFileLoader.cpp @@ -692,7 +692,7 @@ bool DiskCachingFileLoaderCache::LockCacheFile(bool lockStatus) { // TODO: Also use flock where supported? if (lockStatus) { if ((flags_ & FLAG_LOCKED) != 0) { - ERROR_LOG(LOADER, "Could not lock disk cache file for %s", origPath_.c_str()); + ERROR_LOG(LOADER, "Could not lock disk cache file for %s (already locked)", origPath_.c_str()); return false; } flags_ |= FLAG_LOCKED; diff --git a/Core/FileSystems/BlockDevices.cpp b/Core/FileSystems/BlockDevices.cpp index 03fca8d2213f..e0f1847979d9 100644 --- a/Core/FileSystems/BlockDevices.cpp +++ b/Core/FileSystems/BlockDevices.cpp @@ -621,7 +621,7 @@ CHDFileBlockDevice::CHDFileBlockDevice(FileLoader *fileLoader) CHDFileBlockDevice::~CHDFileBlockDevice() { - if (numBlocks > 0) { + if (impl_->chd) { chd_close(impl_->chd); delete[] readBuffer; } @@ -629,6 +629,10 @@ CHDFileBlockDevice::~CHDFileBlockDevice() bool CHDFileBlockDevice::ReadBlock(int blockNumber, u8 *outPtr, bool uncached) { + if (!impl_->chd) { + ERROR_LOG(LOADER, "ReadBlock: CHD not open. %s", fileLoader_->GetPath().c_str()); + return false; + } if ((u32)blockNumber >= numBlocks) { memset(outPtr, 0, GetBlockSize()); return false; diff --git a/Core/FileSystems/BlockDevices.h b/Core/FileSystems/BlockDevices.h index 9dca25e8eb1b..e5f01767c91a 100644 --- a/Core/FileSystems/BlockDevices.h +++ b/Core/FileSystems/BlockDevices.h @@ -147,10 +147,10 @@ class CHDFileBlockDevice : public BlockDevice { private: std::unique_ptr impl_; - u8 *readBuffer; - u32 currentHunk; - u32 blocksPerHunk; - u32 numBlocks; + u8 *readBuffer = nullptr; + u32 currentHunk = 0; + u32 blocksPerHunk = 0; + u32 numBlocks = 0; }; BlockDevice *constructBlockDevice(FileLoader *fileLoader); diff --git a/Core/System.cpp b/Core/System.cpp index 8421cb297e5e..7b157e7fa340 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -190,6 +190,12 @@ static bool LoadSymbolsIfSupported() { if (!g_symbolMap) return false; + if (PSP_CoreParameter().fileToStart.Type() == PathType::HTTP) { + // We don't support loading symbols over HTTP. + g_symbolMap->Clear(); + return true; + } + bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart, ".ppmap")); // Load the old-style map file. if (!result1) diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index abb03555b9ff..031083787228 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -113,7 +113,9 @@ static bool RegisterServer(int port) { bool RemoteISOFileSupported(const std::string &filename) { // Disc-like files. - if (endsWithNoCase(filename, ".cso") || endsWithNoCase(filename, ".iso") || endsWithNoCase(filename, ".chd")) { + // NOTE: chd is temporarily disabled until we can make it use the FileLoader instead of + // trying to re-open the file, since otherwise won't work over HTTP. + if (endsWithNoCase(filename, ".cso") || endsWithNoCase(filename, ".iso")) { return true; } // May work - but won't have supporting files.