diff options
author | Steven Bennetts <steve@lindenlab.com> | 2007-03-02 21:25:50 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2007-03-02 21:25:50 +0000 |
commit | 4dabd9c0472deb49573fdafef2fa413e59703f19 (patch) | |
tree | 06c680d6a2047e03838d6548bccd26c7baf9d652 /indra/llvfs | |
parent | d4462963c6ba5db2088723bbedc7b60f1184c594 (diff) |
merge release@58699 beta-1-14-0@58707 -> release
Diffstat (limited to 'indra/llvfs')
-rw-r--r-- | indra/llvfs/lldir.cpp | 76 | ||||
-rw-r--r-- | indra/llvfs/lldir.h | 4 | ||||
-rw-r--r-- | indra/llvfs/lllfsthread.cpp | 233 | ||||
-rw-r--r-- | indra/llvfs/lllfsthread.h | 54 | ||||
-rw-r--r-- | indra/llvfs/llvfile.cpp | 14 | ||||
-rw-r--r-- | indra/llvfs/llvfs.cpp | 17 | ||||
-rw-r--r-- | indra/llvfs/llvfsthread.cpp | 64 | ||||
-rw-r--r-- | indra/llvfs/llvfsthread.h | 21 |
8 files changed, 227 insertions, 256 deletions
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 9f8d6c08d5..d8d77e6a23 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -183,6 +183,27 @@ const std::string &LLDir::getTempDir() const return mTempDir; } +const std::string LLDir::getCacheDir(bool get_default) const +{ + if (mCacheDir.empty() || get_default) + { + std::string res; + if (getOSUserAppDir().empty()) + { + res = "data"; + } + else + { + res = getOSUserAppDir() + mDirDelimiter + "cache"; + } + return res; + } + else + { + return mCacheDir; + } +} + const std::string &LLDir::getCAFile() const { return mCAFile; @@ -198,7 +219,12 @@ const std::string &LLDir::getSkinDir() const return mSkinDir; } -std::string LLDir::getExpandedFilename(ELLPath location, const std::string &filename) const +std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const +{ + return getExpandedFilename(location, "", filename); +} + +std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subdir, const std::string& in_filename) const { std::string prefix; switch (location) @@ -230,16 +256,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file break; case LL_PATH_CACHE: - if (getOSUserAppDir().empty()) - { - prefix = "data"; - } - else - { - prefix = getOSUserAppDir(); - prefix += mDirDelimiter; - prefix += "cache"; - } + prefix = getCacheDir(); break; case LL_PATH_USER_SETTINGS: @@ -290,6 +307,16 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file llassert(0); } + std::string filename = in_filename; + if (!subdir.empty()) + { + filename = subdir + mDirDelimiter + in_filename; + } + else + { + filename = in_filename; + } + std::string expanded_filename; if (!filename.empty()) { @@ -304,8 +331,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string &file expanded_filename = filename; } } - else - if (!prefix.empty()) + else if (!prefix.empty()) { // Directory only, no file name. expanded_filename = prefix; @@ -405,6 +431,30 @@ void LLDir::setSkinFolder(const std::string &skin_folder) mSkinDir += skin_folder; } +bool LLDir::setCacheDir(const std::string &path) +{ + if (path.empty() ) + { + // reset to default + mCacheDir = ""; + return true; + } + else + { + LLFile::mkdir(path.c_str()); + std::string tempname = path + mDirDelimiter + "temp"; + LLFILE* file = LLFile::fopen(tempname.c_str(),"wt"); + if (file) + { + fclose(file); + LLFile::remove(tempname.c_str()); + mCacheDir = path; + return true; + } + return false; + } +} + void LLDir::dumpCurrentDirectories() { llinfos << "Current Directories:" << llendl; diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index 710dcd1ae3..5389378def 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -60,12 +60,14 @@ class LLDir const std::string &getChatLogsDir() const; // Location of the chat logs dir. const std::string &getPerAccountChatLogsDir() const; // Location of the per account chat logs dir. const std::string &getTempDir() const; // Common temporary directory + const std::string getCacheDir(bool get_default = false) const; // Location of the cache. const std::string &getCAFile() const; // File containing TLS certificate authorities const std::string &getDirDelimiter() const; // directory separator for platform (ie. '\' or '/' or ':') const std::string &getSkinDir() const; // User-specified skin folder. // Expanded filename std::string getExpandedFilename(ELLPath location, const std::string &filename) const; + std::string getExpandedFilename(ELLPath location, const std::string &subdir, const std::string &filename) const; // random filename in common temporary directory std::string getTempFilename() const; @@ -74,6 +76,7 @@ class LLDir virtual void setPerAccountChatLogsDir(const std::string &first, const std::string &last); // Set the per user chat log directory. virtual void setLindenUserDir(const std::string &first, const std::string &last); // Set the linden user dir to this user's dir virtual void setSkinFolder(const std::string &skin_folder); + virtual bool setCacheDir(const std::string &path); virtual void dumpCurrentDirectories(); @@ -91,6 +94,7 @@ protected: std::string mChatLogsDir; // Location for chat logs. std::string mCAFile; // Location of the TLS certificate authority PEM file. std::string mTempDir; + std::string mCacheDir; std::string mDirDelimiter; std::string mSkinDir; // Location for u ser-specified skin info. }; diff --git a/indra/llvfs/lllfsthread.cpp b/indra/llvfs/lllfsthread.cpp index 6af638fd12..598de1d370 100644 --- a/indra/llvfs/lllfsthread.cpp +++ b/indra/llvfs/lllfsthread.cpp @@ -19,10 +19,10 @@ //============================================================================ // Run on MAIN thread //static -void LLLFSThread::initClass(bool local_is_threaded, bool local_run_always) +void LLLFSThread::initClass(bool local_is_threaded) { llassert(sLocal == NULL); - sLocal = new LLLFSThread(local_is_threaded, local_run_always); + sLocal = new LLLFSThread(local_is_threaded); } //static @@ -46,8 +46,9 @@ void LLLFSThread::cleanupClass() //---------------------------------------------------------------------------- -LLLFSThread::LLLFSThread(bool threaded, bool runalways) : - LLQueuedThread("LFS", threaded, runalways) +LLLFSThread::LLLFSThread(bool threaded) : + LLQueuedThread("LFS", threaded), + mPriorityCounter(PRIORITY_LOWBITS) { } @@ -59,250 +60,164 @@ LLLFSThread::~LLLFSThread() //---------------------------------------------------------------------------- LLLFSThread::handle_t LLLFSThread::read(const LLString& filename, /* Flawfinder: ignore */ - U8* buffer, S32 offset, S32 numbytes, U32 priority, U32 flags) + U8* buffer, S32 offset, S32 numbytes, + Responder* responder, U32 priority) { handle_t handle = generateHandle(); - priority = llmax(priority, (U32)PRIORITY_LOW); // All reads are at least PRIORITY_LOW - Request* req = new Request(handle, priority, flags, + if (priority == 0) priority = PRIORITY_NORMAL | priorityCounter(); + else if (priority < PRIORITY_LOW) priority |= PRIORITY_LOW; // All reads are at least PRIORITY_LOW + + Request* req = new Request(this, handle, priority, FILE_READ, filename, - buffer, offset, numbytes); + buffer, offset, numbytes, + responder); bool res = addRequest(req); if (!res) { llerrs << "LLLFSThread::read called after LLLFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - handle = nullHandle(); } return handle; } -S32 LLLFSThread::readImmediate(const LLString& filename, - U8* buffer, S32 offset, S32 numbytes) -{ - handle_t handle = generateHandle(); - - Request* req = new Request(handle, PRIORITY_IMMEDIATE, 0, - FILE_READ, filename, - buffer, offset, numbytes); - - S32 res = addRequest(req) ? 1 : 0; - if (res == 0) - { - llerrs << "LLLFSThread::read called after LLLFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - } - else - { - llverify(waitForResult(handle, false) == true); - res = req->getBytesRead(); - completeRequest(handle); - } - return res; -} - LLLFSThread::handle_t LLLFSThread::write(const LLString& filename, - U8* buffer, S32 offset, S32 numbytes, U32 flags) + U8* buffer, S32 offset, S32 numbytes, + Responder* responder, U32 priority) { handle_t handle = generateHandle(); - Request* req = new Request(handle, 0, flags, - FILE_WRITE, filename, - buffer, offset, numbytes); - - bool res = addRequest(req); - if (!res) - { - llerrs << "LLLFSThread::read called after LLLFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - handle = nullHandle(); - } + if (priority == 0) priority = PRIORITY_LOW | priorityCounter(); - return handle; -} - -S32 LLLFSThread::writeImmediate(const LLString& filename, - U8* buffer, S32 offset, S32 numbytes) -{ - handle_t handle = generateHandle(); - - Request* req = new Request(handle, PRIORITY_IMMEDIATE, 0, + Request* req = new Request(this, handle, priority, FILE_WRITE, filename, - buffer, offset, numbytes); - - S32 res = addRequest(req) ? 1 : 0; - if (res == 0) - { - llerrs << "LLLFSThread::write called after LLLFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - } - else - { - llverify(waitForResult(handle, false) == true); - res = req->getBytesRead(); - completeRequest(handle); - } - return res; -} - - -LLLFSThread::handle_t LLLFSThread::rename(const LLString& filename, const LLString& newname, U32 flags) -{ - handle_t handle = generateHandle(); - - LLString* new_name_str = new LLString(newname); // deleted with Request - Request* req = new Request(handle, 0, flags, - FILE_RENAME, filename, - (U8*)new_name_str, 0, 0); - - bool res = addRequest(req); - if (!res) - { - llerrs << "LLLFSThread::rename called after LLLFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - handle = nullHandle(); - } - - return handle; -} - -LLLFSThread::handle_t LLLFSThread::remove(const LLString& filename, U32 flags) -{ - handle_t handle = generateHandle(); - - Request* req = new Request(handle, 0, flags, - FILE_RENAME, filename, - NULL, 0, 0); + buffer, offset, numbytes, + responder); bool res = addRequest(req); if (!res) { - llerrs << "LLLFSThread::remove called after LLLFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - handle = nullHandle(); + llerrs << "LLLFSThread::read called after LLLFSThread::cleanupClass()" << llendl; } return handle; } //============================================================================ -// Runs on its OWN thread - -bool LLLFSThread::processRequest(QueuedRequest* qreq) -{ - Request *req = (Request*)qreq; - - bool complete = req->processIO(); - - return complete; -} - -//============================================================================ -LLLFSThread::Request::Request(handle_t handle, U32 priority, U32 flags, +LLLFSThread::Request::Request(LLLFSThread* thread, + handle_t handle, U32 priority, operation_t op, const LLString& filename, - U8* buffer, S32 offset, S32 numbytes) : - QueuedRequest(handle, priority, flags), + U8* buffer, S32 offset, S32 numbytes, + Responder* responder) : + QueuedRequest(handle, priority, FLAG_AUTO_COMPLETE), + mThread(thread), mOperation(op), mFileName(filename), mBuffer(buffer), mOffset(offset), mBytes(numbytes), - mBytesRead(0) + mBytesRead(0), + mResponder(responder) { - llassert(mBuffer); - - if (numbytes <= 0 && mOperation != FILE_RENAME && mOperation != FILE_REMOVE) + if (numbytes <= 0) { llwarns << "LLLFSThread: Request with numbytes = " << numbytes << llendl; } } -void LLLFSThread::Request::finishRequest() +LLLFSThread::Request::~Request() { } +// virtual, called from own thread +void LLLFSThread::Request::finishRequest(bool completed) +{ + if (mResponder.notNull()) + { + mResponder->completed(completed ? mBytesRead : 0); + mResponder = NULL; + } +} + void LLLFSThread::Request::deleteRequest() { - if (getStatus() == STATUS_QUEUED || getStatus() == STATUS_ABORT) + if (getStatus() == STATUS_QUEUED) { llerrs << "Attempt to delete a queued LLLFSThread::Request!" << llendl; } - if (mOperation == FILE_WRITE) - { - if (mFlags & AUTO_DELETE) - { - delete mBuffer; - } - } - else if (mOperation == FILE_RENAME) + if (mResponder.notNull()) { - LLString* new_name = (LLString*)mBuffer; - delete new_name; + mResponder->completed(0); + mResponder = NULL; } LLQueuedThread::QueuedRequest::deleteRequest(); } -bool LLLFSThread::Request::processIO() +bool LLLFSThread::Request::processRequest() { bool complete = false; if (mOperation == FILE_READ) { llassert(mOffset >= 0); - apr_file_t* filep = ll_apr_file_open(mFileName, LL_APR_RB); + apr_file_t* filep = ll_apr_file_open(mFileName, LL_APR_RB, mThread->mAPRPoolp); if (!filep) { llwarns << "LLLFS: Unable to read file: " << mFileName << llendl; mBytesRead = 0; // fail return true; } + S32 off; if (mOffset < 0) - ll_apr_file_seek(filep, APR_END, 0); + off = ll_apr_file_seek(filep, APR_END, 0); else - ll_apr_file_seek(filep, APR_SET, mOffset); + off = ll_apr_file_seek(filep, APR_SET, mOffset); + llassert_always(off >= 0); mBytesRead = ll_apr_file_read(filep, mBuffer, mBytes ); apr_file_close(filep); complete = true; - //llinfos << llformat("LLLFSThread::READ '%s': %d bytes",mFileName.c_str(),mBytesRead) << llendl; +// llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl; } else if (mOperation == FILE_WRITE) { - apr_file_t* filep = ll_apr_file_open(mFileName, LL_APR_WB); + apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; + if (mOffset < 0) + flags |= APR_APPEND; + apr_file_t* filep = ll_apr_file_open(mFileName, flags, mThread->mAPRPoolp); if (!filep) { llwarns << "LLLFS: Unable to write file: " << mFileName << llendl; mBytesRead = 0; // fail return true; } - if (mOffset < 0) - ll_apr_file_seek(filep, APR_END, 0); - else - ll_apr_file_seek(filep, APR_SET, mOffset); + if (mOffset >= 0) + { + S32 seek = ll_apr_file_seek(filep, APR_SET, mOffset); + if (seek < 0) + { + apr_file_close(filep); + llwarns << "LLLFS: Unable to write file (seek failed): " << mFileName << llendl; + mBytesRead = 0; // fail + return true; + } + } mBytesRead = ll_apr_file_write(filep, mBuffer, mBytes ); complete = true; apr_file_close(filep); - //llinfos << llformat("LLLFSThread::WRITE '%s': %d bytes",mFileName.c_str(),mBytesRead) << llendl; - } - else if (mOperation == FILE_RENAME) - { - LLString* new_name = (LLString*)mBuffer; - ll_apr_file_rename(mFileName, *new_name); - complete = true; - //llinfos << llformat("LLLFSThread::RENAME '%s': '%s'",mFileName.c_str(),new_name->c_str()) << llendl; - } - else if (mOperation == FILE_REMOVE) - { - ll_apr_file_remove(mFileName); - complete = true; - //llinfos << llformat("LLLFSThread::REMOVE '%s'",mFileName.c_str()) << llendl; +// llinfos << "LLLFSThread::WRITE:" << mFileName << " Bytes: " << mBytesRead << "/" << mBytes << " Offset:" << mOffset << llendl; } else { - llerrs << llformat("LLLFSThread::unknown operation: %d", mOperation) << llendl; + llerrs << "LLLFSThread::unknown operation: " << (S32)mOperation << llendl; } return complete; } //============================================================================ + +LLLFSThread::Responder::~Responder() +{ +} + +//============================================================================ diff --git a/indra/llvfs/lllfsthread.h b/indra/llvfs/lllfsthread.h index 37a6e8bae5..74fd0ffd4d 100644 --- a/indra/llvfs/lllfsthread.h +++ b/indra/llvfs/lllfsthread.h @@ -36,15 +36,24 @@ public: //------------------------------------------------------------------------ public: + class Responder : public LLThreadSafeRefCount + { + public: + virtual ~Responder(); + virtual void completed(S32 bytes) = 0; + }; + class Request : public QueuedRequest { protected: - ~Request() {}; // use deleteRequest() + virtual ~Request(); // use deleteRequest() public: - Request(handle_t handle, U32 priority, U32 flags, + Request(LLLFSThread* thread, + handle_t handle, U32 priority, operation_t op, const LLString& filename, - U8* buffer, S32 offset, S32 numbytes); + U8* buffer, S32 offset, S32 numbytes, + Responder* responder); S32 getBytes() { @@ -67,12 +76,12 @@ public: return mFileName; } - /*virtual*/ void finishRequest(); + /*virtual*/ bool processRequest(); + /*virtual*/ void finishRequest(bool completed); /*virtual*/ void deleteRequest(); - - bool processIO(); private: + LLLFSThread* mThread; operation_t mOperation; LLString mFileName; @@ -80,35 +89,36 @@ public: U8* mBuffer; // dest for reads, source for writes, new UUID for rename S32 mOffset; // offset into file, -1 = append (WRITE only) S32 mBytes; // bytes to read from file, -1 = all - S32 mBytesRead; // bytes read from file + S32 mBytesRead; // bytes read from file + + LLPointer<Responder> mResponder; }; //------------------------------------------------------------------------ public: - LLLFSThread(bool threaded = TRUE, bool runalways = TRUE); + LLLFSThread(bool threaded = TRUE); ~LLLFSThread(); // Return a Request handle handle_t read(const LLString& filename, /* Flawfinder: ignore */ - U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0); + U8* buffer, S32 offset, S32 numbytes, + Responder* responder, U32 pri=0); handle_t write(const LLString& filename, - U8* buffer, S32 offset, S32 numbytes, U32 flags = 0); - handle_t rename(const LLString& filename, const LLString& newname, U32 flags = 0); - handle_t remove(const LLString& filename, U32 flags = 0); + U8* buffer, S32 offset, S32 numbytes, + Responder* responder, U32 pri=0); - // Return number of bytes read - S32 readImmediate(const LLString& filename, - U8* buffer, S32 offset, S32 numbytes); - S32 writeImmediate(const LLString& filename, - U8* buffer, S32 offset, S32 numbytes); - - static void initClass(bool local_is_threaded = TRUE, bool run_always = TRUE); // Setup sLocal + // Misc + U32 priorityCounter() { return mPriorityCounter-- & PRIORITY_LOWBITS; } // Use to order IO operations + + // static initializers + static void initClass(bool local_is_threaded = TRUE); // Setup sLocal static S32 updateClass(U32 ms_elapsed); static void cleanupClass(); // Delete sLocal -protected: - /*virtual*/ bool processRequest(QueuedRequest* req); - + +private: + U32 mPriorityCounter; + public: static LLLFSThread* sLocal; // Default local file thread }; diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp index a4612233d3..ae45c8fe42 100644 --- a/indra/llvfs/llvfile.cpp +++ b/indra/llvfs/llvfile.cpp @@ -51,12 +51,12 @@ LLVFile::~LLVFile() { if (!(mMode & LLVFile::WRITE)) { - // llwarns << "Destroying LLVFile with pending async read/write, aborting..." << llendl; - sVFSThread->abortRequest(mHandle, LLVFSThread::AUTO_COMPLETE); + //llwarns << "Destroying LLVFile with pending async read/write, aborting..." << llendl; + sVFSThread->setFlags(mHandle, LLVFSThread::FLAG_AUTO_COMPLETE | LLVFSThread::FLAG_ABORT); } else // WRITE { - sVFSThread->setFlags(mHandle, LLVFSThread::AUTO_COMPLETE); + sVFSThread->setFlags(mHandle, LLVFSThread::FLAG_AUTO_COMPLETE); } } } @@ -194,8 +194,8 @@ BOOL LLVFile::write(const U8 *buffer, S32 bytes) S32 offset = -1; mHandle = sVFSThread->write(mVFS, mFileID, mFileType, writebuf, offset, bytes, - LLVFSThread::AUTO_COMPLETE | LLVFSThread::AUTO_DELETE); - mHandle = LLVFSThread::nullHandle(); // AUTO_COMPLETE means we don't track this + LLVFSThread::FLAG_AUTO_COMPLETE | LLVFSThread::FLAG_AUTO_DELETE); + mHandle = LLVFSThread::nullHandle(); // FLAG_AUTO_COMPLETE means we don't track this } else { @@ -304,7 +304,7 @@ BOOL LLVFile::setMaxSize(S32 size) } if (sVFSThread->isPaused()) { - sVFSThread->updateQueue(0); + sVFSThread->update(0); } ms_sleep(10); } @@ -408,7 +408,7 @@ void LLVFile::waitForLock(EVFSLock lock) { if (sVFSThread->isPaused()) { - sVFSThread->updateQueue(0); + sVFSThread->update(0); } ms_sleep(1); } diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp index 592f74dd02..e4749041ee 100644 --- a/indra/llvfs/llvfs.cpp +++ b/indra/llvfs/llvfs.cpp @@ -771,12 +771,17 @@ BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type } // round all sizes upward to KB increments - if (max_size & FILE_BLOCK_MASK) + // SJB: Need to not round for the new texture-pipeline code so we know the correct + // max file size. Need to investigate the potential problems with this... + if (file_type != LLAssetType::AT_TEXTURE) { - max_size += FILE_BLOCK_MASK; - max_size &= ~FILE_BLOCK_MASK; - } - + if (max_size & FILE_BLOCK_MASK) + { + max_size += FILE_BLOCK_MASK; + max_size &= ~FILE_BLOCK_MASK; + } + } + if (block && block->mLength > 0) { block->mAccessTime = (U32)time(NULL); @@ -1998,7 +2003,7 @@ LLString get_extension(LLAssetType::EType type) switch(type) { case LLAssetType::AT_TEXTURE: - extension = ".jp2"; // ".j2c"; // IrfanView recognizes .jp2 -sjb + extension = ".j2c"; break; case LLAssetType::AT_SOUND: extension = ".ogg"; diff --git a/indra/llvfs/llvfsthread.cpp b/indra/llvfs/llvfsthread.cpp index 619c1b9bb3..57cdb7626e 100644 --- a/indra/llvfs/llvfsthread.cpp +++ b/indra/llvfs/llvfsthread.cpp @@ -20,10 +20,10 @@ //============================================================================ // Run on MAIN thread //static -void LLVFSThread::initClass(bool local_is_threaded, bool local_run_always) +void LLVFSThread::initClass(bool local_is_threaded) { llassert(sLocal == NULL); - sLocal = new LLVFSThread(local_is_threaded, local_run_always); + sLocal = new LLVFSThread(local_is_threaded); } //static @@ -47,8 +47,8 @@ void LLVFSThread::cleanupClass() //---------------------------------------------------------------------------- -LLVFSThread::LLVFSThread(bool threaded, bool runalways) : - LLQueuedThread("VFS", threaded, runalways) +LLVFSThread::LLVFSThread(bool threaded) : + LLQueuedThread("VFS", threaded) { } @@ -145,38 +145,26 @@ S32 LLVFSThread::writeImmediate(LLVFS* vfs, const LLUUID &file_id, const LLAsset } -LLVFSThread::handle_t LLVFSThread::rename(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, - const LLUUID &new_id, const LLAssetType::EType new_type, U32 flags) -{ - handle_t handle = generateHandle(); +// LLVFSThread::handle_t LLVFSThread::rename(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, +// const LLUUID &new_id, const LLAssetType::EType new_type, U32 flags) +// { +// handle_t handle = generateHandle(); - LLUUID* new_idp = new LLUUID(new_id); // deleted with Request - // new_type is passed as "numbytes" - Request* req = new Request(handle, 0, flags, FILE_RENAME, vfs, file_id, file_type, - (U8*)new_idp, 0, (S32)new_type); +// LLUUID* new_idp = new LLUUID(new_id); // deleted with Request +// // new_type is passed as "numbytes" +// Request* req = new Request(handle, 0, flags, FILE_RENAME, vfs, file_id, file_type, +// (U8*)new_idp, 0, (S32)new_type); - bool res = addRequest(req); - if (!res) - { - llerrs << "LLVFSThread::read called after LLVFSThread::cleanupClass()" << llendl; - req->deleteRequest(); - handle = nullHandle(); - } +// bool res = addRequest(req); +// if (!res) +// { +// llerrs << "LLVFSThread::read called after LLVFSThread::cleanupClass()" << llendl; +// req->deleteRequest(); +// handle = nullHandle(); +// } - return handle; -} - -//============================================================================ -// Runs on its OWN thread - -bool LLVFSThread::processRequest(QueuedRequest* qreq) -{ - Request *req = (Request*)qreq; - - bool complete = req->processIO(); - - return complete; -} +// return handle; +// } //============================================================================ @@ -223,7 +211,7 @@ LLVFSThread::Request::Request(handle_t handle, U32 priority, U32 flags, } // dec locks as soon as a request finishes -void LLVFSThread::Request::finishRequest() +void LLVFSThread::Request::finishRequest(bool completed) { if (mOperation == FILE_WRITE) { @@ -241,13 +229,13 @@ void LLVFSThread::Request::finishRequest() void LLVFSThread::Request::deleteRequest() { - if (getStatus() == STATUS_QUEUED || getStatus() == STATUS_ABORT) + if (getStatus() == STATUS_QUEUED) { llerrs << "Attempt to delete a queued LLVFSThread::Request!" << llendl; } if (mOperation == FILE_WRITE) { - if (mFlags & AUTO_DELETE) + if (mFlags & FLAG_AUTO_DELETE) { delete [] mBuffer; } @@ -260,7 +248,7 @@ void LLVFSThread::Request::deleteRequest() LLQueuedThread::QueuedRequest::deleteRequest(); } -bool LLVFSThread::Request::processIO() +bool LLVFSThread::Request::processRequest() { bool complete = false; if (mOperation == FILE_READ) @@ -283,7 +271,7 @@ bool LLVFSThread::Request::processIO() mVFS->renameFile(mFileID, mFileType, *new_idp, new_type); mFileID = *new_idp; complete = true; - //llinfos << llformat("LLVFSThread::WRITE '%s': %d bytes arg:%d",getFilename(),mBytesRead) << llendl; + //llinfos << llformat("LLVFSThread::RENAME '%s': %d bytes arg:%d",getFilename(),mBytesRead) << llendl; } else { diff --git a/indra/llvfs/llvfsthread.h b/indra/llvfs/llvfsthread.h index 6839338813..ea7c5123b0 100644 --- a/indra/llvfs/llvfsthread.h +++ b/indra/llvfs/llvfsthread.h @@ -69,10 +69,9 @@ public: return std::string(tbuf); } - /*virtual*/ void finishRequest(); + /*virtual*/ bool processRequest(); + /*virtual*/ void finishRequest(bool completed); /*virtual*/ void deleteRequest(); - - bool processIO(); private: operation_t mOperation; @@ -90,10 +89,10 @@ public: //------------------------------------------------------------------------ public: static std::string sDataPath; - static void setDataPath(const std::string& path) { sDataPath = path; } + static LLVFSThread* sLocal; // Default worker thread public: - LLVFSThread(bool threaded = TRUE, bool runalways = TRUE); + LLVFSThread(bool threaded = TRUE); ~LLVFSThread(); // Return a Request handle @@ -101,8 +100,9 @@ public: U8* buffer, S32 offset, S32 numbytes, U32 pri=PRIORITY_NORMAL, U32 flags = 0); handle_t write(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, U8* buffer, S32 offset, S32 numbytes, U32 flags); - handle_t rename(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, - const LLUUID &new_id, const LLAssetType::EType new_type, U32 flags); + // SJB: rename seems to have issues, especially when threaded +// handle_t rename(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, +// const LLUUID &new_id, const LLAssetType::EType new_type, U32 flags); // Return number of bytes read S32 readImmediate(LLVFS* vfs, const LLUUID &file_id, const LLAssetType::EType file_type, U8* buffer, S32 offset, S32 numbytes); @@ -111,12 +111,11 @@ public: /*virtual*/ bool processRequest(QueuedRequest* req); - static void initClass(bool local_is_threaded = TRUE, bool run_always = TRUE); // Setup sLocal +public: + static void initClass(bool local_is_threaded = TRUE); // Setup sLocal static S32 updateClass(U32 ms_elapsed); static void cleanupClass(); // Delete sLocal - -public: - static LLVFSThread* sLocal; // Default worker thread + static void setDataPath(const std::string& path) { sDataPath = path; } }; //============================================================================ |