diff options
Diffstat (limited to 'indra/llvfs/lllfsthread.cpp')
-rw-r--r-- | indra/llvfs/lllfsthread.cpp | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/indra/llvfs/lllfsthread.cpp b/indra/llvfs/lllfsthread.cpp index 8d2dc72ffc..3d3ed9f6d4 100644 --- a/indra/llvfs/lllfsthread.cpp +++ b/indra/llvfs/lllfsthread.cpp @@ -2,35 +2,29 @@ * @file lllfsthread.cpp * @brief LLLFSThread base class * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * 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. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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 * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ #include "linden_common.h" -#include "llmath.h" #include "lllfsthread.h" #include "llstl.h" #include "llapr.h" @@ -73,6 +67,10 @@ LLLFSThread::LLLFSThread(bool threaded) : LLQueuedThread("LFS", threaded), mPriorityCounter(PRIORITY_LOWBITS) { + if(!mLocalAPRFilePoolp) + { + mLocalAPRFilePoolp = new LLVolatileAPRPool() ; + } } LLLFSThread::~LLLFSThread() @@ -82,7 +80,7 @@ LLLFSThread::~LLLFSThread() //---------------------------------------------------------------------------- -LLLFSThread::handle_t LLLFSThread::read(const LLString& filename, /* Flawfinder: ignore */ +LLLFSThread::handle_t LLLFSThread::read(const std::string& filename, /* Flawfinder: ignore */ U8* buffer, S32 offset, S32 numbytes, Responder* responder, U32 priority) { @@ -105,7 +103,7 @@ LLLFSThread::handle_t LLLFSThread::read(const LLString& filename, /* Flawfinder: return handle; } -LLLFSThread::handle_t LLLFSThread::write(const LLString& filename, +LLLFSThread::handle_t LLLFSThread::write(const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder, U32 priority) { @@ -131,7 +129,7 @@ LLLFSThread::handle_t LLLFSThread::write(const LLString& filename, LLLFSThread::Request::Request(LLLFSThread* thread, handle_t handle, U32 priority, - operation_t op, const LLString& filename, + operation_t op, const std::string& filename, U8* buffer, S32 offset, S32 numbytes, Responder* responder) : QueuedRequest(handle, priority, FLAG_AUTO_COMPLETE), @@ -184,8 +182,9 @@ bool LLLFSThread::Request::processRequest() if (mOperation == FILE_READ) { llassert(mOffset >= 0); - apr_file_t* filep = ll_apr_file_open(mFileName, LL_APR_RB, mThread->mAPRPoolp); - if (!filep) + LLAPRFile infile ; // auto-closes + infile.open(mFileName, LL_APR_RB, mThread->getLocalAPRFilePool()); + if (!infile.getFileHandle()) { llwarns << "LLLFS: Unable to read file: " << mFileName << llendl; mBytesRead = 0; // fail @@ -193,12 +192,11 @@ bool LLLFSThread::Request::processRequest() } S32 off; if (mOffset < 0) - off = ll_apr_file_seek(filep, APR_END, 0); + off = infile.seek(APR_END, 0); else - off = ll_apr_file_seek(filep, APR_SET, mOffset); + off = infile.seek(APR_SET, mOffset); llassert_always(off >= 0); - mBytesRead = ll_apr_file_read(filep, mBuffer, mBytes ); - apr_file_close(filep); + mBytesRead = infile.read(mBuffer, mBytes ); complete = true; // llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl; } @@ -207,8 +205,9 @@ bool LLLFSThread::Request::processRequest() 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) + LLAPRFile outfile ; // auto-closes + outfile.open(mFileName, flags, mThread->getLocalAPRFilePool()); + if (!outfile.getFileHandle()) { llwarns << "LLLFS: Unable to write file: " << mFileName << llendl; mBytesRead = 0; // fail @@ -216,18 +215,16 @@ bool LLLFSThread::Request::processRequest() } if (mOffset >= 0) { - S32 seek = ll_apr_file_seek(filep, APR_SET, mOffset); + S32 seek = outfile.seek(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 ); + mBytesRead = outfile.write(mBuffer, mBytes ); complete = true; - apr_file_close(filep); // llinfos << "LLLFSThread::WRITE:" << mFileName << " Bytes: " << mBytesRead << "/" << mBytes << " Offset:" << mOffset << llendl; } else |