summaryrefslogtreecommitdiff
path: root/indra/llcache
diff options
context:
space:
mode:
authorCallum Prentice <callum@gmail.com>2020-09-16 21:12:53 -0700
committerCallum Prentice <callum@gmail.com>2020-09-16 21:12:53 -0700
commit2e6f5164116e084fe35f952180c3f7092ad8350f (patch)
treeefb02e626773fd54d75cc73f0ebfbca862057b24 /indra/llcache
parent3fc07dea01795b31c37dcd093ec73d190a1e188a (diff)
Renamed the references to LLVFile and llvfile.* source code plus cmake scripts to use a different name - lldiskcache - since that more closely resembles what it is (or will be) now that the VFA is no more
Diffstat (limited to 'indra/llcache')
-rw-r--r--indra/llcache/CMakeLists.txt6
-rw-r--r--indra/llcache/lldiskcache.cpp (renamed from indra/llcache/llvfile.cpp)66
-rw-r--r--indra/llcache/lldiskcache.h (renamed from indra/llcache/llvfile.h)14
-rw-r--r--indra/llcache/llpidlock.cpp276
-rw-r--r--indra/llcache/llpidlock.h60
5 files changed, 42 insertions, 380 deletions
diff --git a/indra/llcache/CMakeLists.txt b/indra/llcache/CMakeLists.txt
index ab84bd96a0..379e3ebdbf 100644
--- a/indra/llcache/CMakeLists.txt
+++ b/indra/llcache/CMakeLists.txt
@@ -15,8 +15,7 @@ set(llcache_SOURCE_FILES
lldir.cpp
lldiriterator.cpp
lllfsthread.cpp
- llpidlock.cpp
- llvfile.cpp
+ lldiskcache.cpp
)
set(llcache_HEADER_FILES
@@ -26,8 +25,7 @@ set(llcache_HEADER_FILES
lldirguard.h
lldiriterator.h
lllfsthread.h
- llpidlock.h
- llvfile.h
+ lldiskcache.h
)
if (DARWIN)
diff --git a/indra/llcache/llvfile.cpp b/indra/llcache/lldiskcache.cpp
index be753244c0..af93049e07 100644
--- a/indra/llcache/llvfile.cpp
+++ b/indra/llcache/lldiskcache.cpp
@@ -1,5 +1,5 @@
/**
- * @file llvfile.cpp
+ * @file lldiskcache.cpp
* @brief Implementation of virtual file
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
@@ -26,7 +26,7 @@
#include "linden_common.h"
-#include "llvfile.h"
+#include "lldiskcache.h"
#include "llerror.h"
#include "llthread.h"
@@ -37,14 +37,14 @@
#include <fstream>
#include "lldir.h"
-const S32 LLVFile::READ = 0x00000001;
-const S32 LLVFile::WRITE = 0x00000002;
-const S32 LLVFile::READ_WRITE = 0x00000003; // LLVFile::READ & LLVFile::WRITE
-const S32 LLVFile::APPEND = 0x00000006; // 0x00000004 & LLVFile::WRITE
+const S32 LLDiskCache::READ = 0x00000001;
+const S32 LLDiskCache::WRITE = 0x00000002;
+const S32 LLDiskCache::READ_WRITE = 0x00000003; // LLDiskCache::READ & LLDiskCache::WRITE
+const S32 LLDiskCache::APPEND = 0x00000006; // 0x00000004 & LLDiskCache::WRITE
static LLTrace::BlockTimerStatHandle FTM_VFILE_WAIT("VFile Wait");
-LLVFile::LLVFile(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode)
+LLDiskCache::LLDiskCache(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode)
{
mFileType = file_type;
mFileID = file_id;
@@ -54,7 +54,7 @@ LLVFile::LLVFile(const LLUUID &file_id, const LLAssetType::EType file_type, S32
mMode = mode;
}
-LLVFile::~LLVFile()
+LLDiskCache::~LLDiskCache()
{
}
@@ -124,7 +124,7 @@ const std::string idToFilepath(const std::string id, LLAssetType::EType at)
}
// static
-bool LLVFile::getExists(const LLUUID &file_id, const LLAssetType::EType file_type)
+bool LLDiskCache::getExists(const LLUUID &file_id, const LLAssetType::EType file_type)
{
std::string id_str;
file_id.toString(id_str);
@@ -140,7 +140,7 @@ bool LLVFile::getExists(const LLUUID &file_id, const LLAssetType::EType file_typ
}
// static
-bool LLVFile::removeFile(const LLUUID &file_id, const LLAssetType::EType file_type)
+bool LLDiskCache::removeFile(const LLUUID &file_id, const LLAssetType::EType file_type)
{
std::string id_str;
file_id.toString(id_str);
@@ -152,7 +152,7 @@ bool LLVFile::removeFile(const LLUUID &file_id, const LLAssetType::EType file_ty
}
// static
-bool LLVFile::renameFile(const LLUUID &old_file_id, const LLAssetType::EType old_file_type,
+bool LLDiskCache::renameFile(const LLUUID &old_file_id, const LLAssetType::EType old_file_type,
const LLUUID &new_file_id, const LLAssetType::EType new_file_type)
{
std::string old_id_str;
@@ -175,7 +175,7 @@ bool LLVFile::renameFile(const LLUUID &old_file_id, const LLAssetType::EType old
}
// static
-S32 LLVFile::getFileSize(const LLUUID &file_id, const LLAssetType::EType file_type)
+S32 LLDiskCache::getFileSize(const LLUUID &file_id, const LLAssetType::EType file_type)
{
std::string id_str;
file_id.toString(id_str);
@@ -192,7 +192,7 @@ S32 LLVFile::getFileSize(const LLUUID &file_id, const LLAssetType::EType file_ty
return file_size;
}
-BOOL LLVFile::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
+BOOL LLDiskCache::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
{
BOOL success = TRUE;
@@ -232,7 +232,7 @@ BOOL LLVFile::read(U8 *buffer, S32 bytes, BOOL async, F32 priority)
return success;
}
-BOOL LLVFile::isReadComplete()
+BOOL LLDiskCache::isReadComplete()
{
if (mReadComplete)
{
@@ -242,17 +242,17 @@ BOOL LLVFile::isReadComplete()
return FALSE;
}
-S32 LLVFile::getLastBytesRead()
+S32 LLDiskCache::getLastBytesRead()
{
return mBytesRead;
}
-BOOL LLVFile::eof()
+BOOL LLDiskCache::eof()
{
return mPosition >= getSize();
}
-BOOL LLVFile::write(const U8 *buffer, S32 bytes)
+BOOL LLDiskCache::write(const U8 *buffer, S32 bytes)
{
std::string id_str;
mFileID.toString(id_str);
@@ -287,14 +287,14 @@ BOOL LLVFile::write(const U8 *buffer, S32 bytes)
}
//static
-BOOL LLVFile::writeFile(const U8 *buffer, S32 bytes, const LLUUID &uuid, LLAssetType::EType type)
+BOOL LLDiskCache::writeFile(const U8 *buffer, S32 bytes, const LLUUID &uuid, LLAssetType::EType type)
{
- LLVFile file(uuid, type, LLVFile::WRITE);
+ LLDiskCache file(uuid, type, LLDiskCache::WRITE);
file.setMaxSize(bytes);
return file.write(buffer, bytes);
}
-BOOL LLVFile::seek(S32 offset, S32 origin)
+BOOL LLDiskCache::seek(S32 offset, S32 origin)
{
if (-1 == origin)
{
@@ -324,32 +324,32 @@ BOOL LLVFile::seek(S32 offset, S32 origin)
return TRUE;
}
-S32 LLVFile::tell() const
+S32 LLDiskCache::tell() const
{
return mPosition;
}
-S32 LLVFile::getSize()
+S32 LLDiskCache::getSize()
{
- return LLVFile::getFileSize(mFileID, mFileType);
+ return LLDiskCache::getFileSize(mFileID, mFileType);
}
-S32 LLVFile::getMaxSize()
+S32 LLDiskCache::getMaxSize()
{
// offer up a huge size since we don't care what the max is
return INT_MAX;
}
-BOOL LLVFile::setMaxSize(S32 size)
+BOOL LLDiskCache::setMaxSize(S32 size)
{
// we don't care what the max size is so we do nothing
// and return true to indicate all was okay
return TRUE;
}
-BOOL LLVFile::rename(const LLUUID &new_id, const LLAssetType::EType new_type)
+BOOL LLDiskCache::rename(const LLUUID &new_id, const LLAssetType::EType new_type)
{
- LLVFile::renameFile(mFileID, mFileType, new_id, new_type);
+ LLDiskCache::renameFile(mFileID, mFileType, new_id, new_type);
mFileID = new_id;
mFileType = new_type;
@@ -357,31 +357,31 @@ BOOL LLVFile::rename(const LLUUID &new_id, const LLAssetType::EType new_type)
return TRUE;
}
-BOOL LLVFile::remove()
+BOOL LLDiskCache::remove()
{
- LLVFile::removeFile(mFileID, mFileType);
+ LLDiskCache::removeFile(mFileID, mFileType);
return TRUE;
}
// static
-void LLVFile::initClass()
+void LLDiskCache::initClass()
{
}
// static
-void LLVFile::cleanupClass()
+void LLDiskCache::cleanupClass()
{
}
-bool LLVFile::isLocked()
+bool LLDiskCache::isLocked()
{
// I don't think we care about this test since there is no locking
// TODO: remove this function and calling sites?
return FALSE;
}
-void LLVFile::waitForLock()
+void LLDiskCache::waitForLock()
{
// TODO: remove this function and calling sites?
}
diff --git a/indra/llcache/llvfile.h b/indra/llcache/lldiskcache.h
index 30130df340..7ad06a8689 100644
--- a/indra/llcache/llvfile.h
+++ b/indra/llcache/lldiskcache.h
@@ -1,5 +1,5 @@
/**
- * @file llvfile.h
+ * @file lldiskcacke.h
* @brief Definition of virtual file
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
@@ -24,17 +24,17 @@
* $/LicenseInfo$
*/
-#ifndef LL_LLVFILE_H
-#define LL_LLVFILE_H
+#ifndef LL_LLDISKCACHE_H
+#define LL_LLDISKCACHE_H
#include "lluuid.h"
#include "llassettype.h"
-class LLVFile
+class LLDiskCache
{
public:
- LLVFile(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLVFile::READ);
- ~LLVFile();
+ LLDiskCache(const LLUUID &file_id, const LLAssetType::EType file_type, S32 mode = LLDiskCache::READ);
+ ~LLDiskCache();
BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */
BOOL isReadComplete();
@@ -79,4 +79,4 @@ protected:
S32 mBytesRead;
};
-#endif
+#endif // LL_LLDISKCACHE_H
diff --git a/indra/llcache/llpidlock.cpp b/indra/llcache/llpidlock.cpp
deleted file mode 100644
index f770e93d45..0000000000
--- a/indra/llcache/llpidlock.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/**
- * @file llformat.cpp
- * @date January 2007
- * @brief string formatting utility
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-
-#include "llapr.h" // thread-related functions
-#include "llpidlock.h"
-#include "lldir.h"
-#include "llsd.h"
-#include "llsdserialize.h"
-#include "llnametable.h"
-#include "llframetimer.h"
-
-#if LL_WINDOWS //For windows platform.
-
-#include <windows.h>
-
-bool isProcessAlive(U32 pid)
-{
- return (bool) GetProcessVersion((DWORD)pid);
-}
-
-#else //Everyone Else
-bool isProcessAlive(U32 pid)
-{
- return (bool) kill( (pid_t)pid, 0);
-}
-#endif //Everyone else.
-
-
-
-class LLPidLockFile
-{
- public:
- LLPidLockFile( ) :
- mAutosave(false),
- mSaving(false),
- mWaiting(false),
- mPID(getpid()),
- mNameTable(NULL),
- mClean(true)
- {
- mLockName = gDirUtilp->getTempDir() + gDirUtilp->getDirDelimiter() + "savelock";
- }
- bool requestLock(LLNameTable<void *> *name_table, bool autosave,
- bool force_immediate=FALSE, F32 timeout=300.0);
- bool checkLock();
- void releaseLock();
-
- private:
- void writeLockFile(LLSD pids);
- public:
- static LLPidLockFile& instance(); // return the singleton black list file
-
- bool mAutosave;
- bool mSaving;
- bool mWaiting;
- LLFrameTimer mTimer;
- U32 mPID;
- std::string mLockName;
- std::string mSaveName;
- LLSD mPIDS_sd;
- LLNameTable<void*> *mNameTable;
- bool mClean;
-};
-
-LLPidLockFile& LLPidLockFile::instance()
-{
- static LLPidLockFile the_file;
- return the_file;
-}
-
-void LLPidLockFile::writeLockFile(LLSD pids)
-{
- llofstream ofile(mLockName.c_str());
-
- if (!LLSDSerialize::toXML(pids,ofile))
- {
- LL_WARNS() << "Unable to write concurrent save lock file." << LL_ENDL;
- }
- ofile.close();
-}
-
-bool LLPidLockFile::requestLock(LLNameTable<void *> *name_table, bool autosave,
- bool force_immediate, F32 timeout)
-{
- bool readyToSave = FALSE;
-
- if (mSaving) return FALSE; //Bail out if we're currently saving. Will not queue another save.
-
- if (!mWaiting){
- mNameTable=name_table;
- mAutosave = autosave;
- }
-
- LLSD out_pids;
- out_pids.append( (LLSD::Integer)mPID );
-
- llifstream ifile(mLockName.c_str());
-
- if (ifile.is_open())
- { //If file exists, we need to decide whether or not to continue.
- if ( force_immediate
- || mTimer.hasExpired() ) //Only deserialize if we REALLY need to.
- {
-
- LLSD in_pids;
-
- LLSDSerialize::fromXML(in_pids, ifile);
-
- //Clean up any dead PIDS that might be in there.
- for (LLSD::array_iterator i=in_pids.beginArray();
- i !=in_pids.endArray();
- ++i)
- {
- U32 stored_pid=(*i).asInteger();
-
- if (isProcessAlive(stored_pid))
- {
- out_pids.append( (*i) );
- }
- }
-
- readyToSave=TRUE;
- }
- ifile.close();
- }
- else
- {
- readyToSave=TRUE;
- }
-
- if (!mWaiting) //Not presently waiting to save. Queue up.
- {
- mTimer.resetWithExpiry(timeout);
- mWaiting=TRUE;
- }
-
- if (readyToSave)
- { //Potential race condition won't kill us. Ignore it.
- writeLockFile(out_pids);
- mSaving=TRUE;
- }
-
- return readyToSave;
-}
-
-bool LLPidLockFile::checkLock()
-{
- return mWaiting;
-}
-
-void LLPidLockFile::releaseLock()
-{
- llifstream ifile(mLockName.c_str());
- LLSD in_pids;
- LLSD out_pids;
- bool write_file=FALSE;
-
- LLSDSerialize::fromXML(in_pids, ifile);
-
- //Clean up this PID and any dead ones.
- for (LLSD::array_iterator i=in_pids.beginArray();
- i !=in_pids.endArray();
- ++i)
- {
- U32 stored_pid=(*i).asInteger();
-
- if (stored_pid != mPID && isProcessAlive(stored_pid))
- {
- out_pids.append( (*i) );
- write_file=TRUE;
- }
- }
- ifile.close();
-
- if (write_file)
- {
- writeLockFile(out_pids);
- }
- else
- {
- unlink(mLockName.c_str());
- }
-
- mSaving=FALSE;
- mWaiting=FALSE;
-}
-
-//LLPidLock
-
-void LLPidLock::initClass() {
- (void) LLPidLockFile::instance();
-}
-
-bool LLPidLock::checkLock()
-{
- return LLPidLockFile::instance().checkLock();
-}
-
-bool LLPidLock::requestLock(LLNameTable<void *> *name_table, bool autosave,
- bool force_immediate, F32 timeout)
-{
- return LLPidLockFile::instance().requestLock(name_table,autosave,force_immediate,timeout);
-}
-
-void LLPidLock::releaseLock()
-{
- return LLPidLockFile::instance().releaseLock();
-}
-
-bool LLPidLock::isClean()
-{
- return LLPidLockFile::instance().mClean;
-}
-
-//getters
-LLNameTable<void *> * LLPidLock::getNameTable()
-{
- return LLPidLockFile::instance().mNameTable;
-}
-
-bool LLPidLock::getAutosave()
-{
- return LLPidLockFile::instance().mAutosave;
-}
-
-bool LLPidLock::getClean()
-{
- return LLPidLockFile::instance().mClean;
-}
-
-std::string LLPidLock::getSaveName()
-{
- return LLPidLockFile::instance().mSaveName;
-}
-
-//setters
-void LLPidLock::setClean(bool clean)
-{
- LLPidLockFile::instance().mClean=clean;
-}
-
-void LLPidLock::setSaveName(std::string savename)
-{
- LLPidLockFile::instance().mSaveName=savename;
-}
-
-S32 LLPidLock::getPID()
-{
- return (S32)getpid();
-}
diff --git a/indra/llcache/llpidlock.h b/indra/llcache/llpidlock.h
deleted file mode 100644
index 334f26bb29..0000000000
--- a/indra/llcache/llpidlock.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * @file llpidlock.h
- * @brief System information debugging classes.
- *
- * $LicenseInfo:firstyear=2001&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_PIDLOCK_H
-#define LL_PIDLOCK_H
-#include "llnametable.h"
-
-class LLSD;
-class LLFrameTimer;
-
-#if !LL_WINDOWS //For non-windows platforms.
-#include <signal.h>
-#endif
-
-namespace LLPidLock
-{
- void initClass(); // { (void) LLPidLockFile::instance(); }
-
- bool requestLock( LLNameTable<void *> *name_table=NULL, bool autosave=TRUE,
- bool force_immediate=FALSE, F32 timeout=300.0);
- bool checkLock();
- void releaseLock();
- bool isClean();
-
- //getters
- LLNameTable<void *> * getNameTable();
- bool getAutosave();
- bool getClean();
- std::string getSaveName();
- S32 getPID();
-
- //setters
- void setClean(bool clean);
- void setSaveName(std::string savename);
-};
-
-#endif // LL_PIDLOCK_H