aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llvfs/lllfsthread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llvfs/lllfsthread.cpp')
-rw-r--r--linden/indra/llvfs/lllfsthread.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/linden/indra/llvfs/lllfsthread.cpp b/linden/indra/llvfs/lllfsthread.cpp
index bdcf61f..704e1ab 100644
--- a/linden/indra/llvfs/lllfsthread.cpp
+++ b/linden/indra/llvfs/lllfsthread.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -72,6 +73,10 @@ LLLFSThread::LLLFSThread(bool threaded) :
72 LLQueuedThread("LFS", threaded), 73 LLQueuedThread("LFS", threaded),
73 mPriorityCounter(PRIORITY_LOWBITS) 74 mPriorityCounter(PRIORITY_LOWBITS)
74{ 75{
76 if(!mLocalAPRFilePoolp)
77 {
78 mLocalAPRFilePoolp = new LLVolatileAPRPool() ;
79 }
75} 80}
76 81
77LLLFSThread::~LLLFSThread() 82LLLFSThread::~LLLFSThread()
@@ -183,8 +188,9 @@ bool LLLFSThread::Request::processRequest()
183 if (mOperation == FILE_READ) 188 if (mOperation == FILE_READ)
184 { 189 {
185 llassert(mOffset >= 0); 190 llassert(mOffset >= 0);
186 apr_file_t* filep = ll_apr_file_open(mFileName, LL_APR_RB, mThread->mAPRPoolp); 191 LLAPRFile infile ;
187 if (!filep) 192 infile.open(mThread->getLocalAPRFilePool(), mFileName, LL_APR_RB);
193 if (!infile.getFileHandle())
188 { 194 {
189 llwarns << "LLLFS: Unable to read file: " << mFileName << llendl; 195 llwarns << "LLLFS: Unable to read file: " << mFileName << llendl;
190 mBytesRead = 0; // fail 196 mBytesRead = 0; // fail
@@ -192,13 +198,13 @@ bool LLLFSThread::Request::processRequest()
192 } 198 }
193 S32 off; 199 S32 off;
194 if (mOffset < 0) 200 if (mOffset < 0)
195 off = ll_apr_file_seek(filep, APR_END, 0); 201 off = infile.seek(APR_END, 0);
196 else 202 else
197 off = ll_apr_file_seek(filep, APR_SET, mOffset); 203 off = infile.seek(APR_SET, mOffset);
198 llassert_always(off >= 0); 204 llassert_always(off >= 0);
199 mBytesRead = ll_apr_file_read(filep, mBuffer, mBytes ); 205 mBytesRead = infile.read(mBuffer, mBytes );
200 apr_file_close(filep);
201 complete = true; 206 complete = true;
207 infile.close() ;
202// llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl; 208// llinfos << "LLLFSThread::READ:" << mFileName << " Bytes: " << mBytesRead << llendl;
203 } 209 }
204 else if (mOperation == FILE_WRITE) 210 else if (mOperation == FILE_WRITE)
@@ -206,8 +212,9 @@ bool LLLFSThread::Request::processRequest()
206 apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; 212 apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY;
207 if (mOffset < 0) 213 if (mOffset < 0)
208 flags |= APR_APPEND; 214 flags |= APR_APPEND;
209 apr_file_t* filep = ll_apr_file_open(mFileName, flags, mThread->mAPRPoolp); 215 LLAPRFile outfile ;
210 if (!filep) 216 outfile.open(mThread->getLocalAPRFilePool(), mFileName, flags);
217 if (!outfile.getFileHandle())
211 { 218 {
212 llwarns << "LLLFS: Unable to write file: " << mFileName << llendl; 219 llwarns << "LLLFS: Unable to write file: " << mFileName << llendl;
213 mBytesRead = 0; // fail 220 mBytesRead = 0; // fail
@@ -215,18 +222,17 @@ bool LLLFSThread::Request::processRequest()
215 } 222 }
216 if (mOffset >= 0) 223 if (mOffset >= 0)
217 { 224 {
218 S32 seek = ll_apr_file_seek(filep, APR_SET, mOffset); 225 S32 seek = outfile.seek(APR_SET, mOffset);
219 if (seek < 0) 226 if (seek < 0)
220 { 227 {
221 apr_file_close(filep);
222 llwarns << "LLLFS: Unable to write file (seek failed): " << mFileName << llendl; 228 llwarns << "LLLFS: Unable to write file (seek failed): " << mFileName << llendl;
223 mBytesRead = 0; // fail 229 mBytesRead = 0; // fail
224 return true; 230 return true;
225 } 231 }
226 } 232 }
227 mBytesRead = ll_apr_file_write(filep, mBuffer, mBytes ); 233 mBytesRead = outfile.write(mBuffer, mBytes );
228 complete = true; 234 complete = true;
229 apr_file_close(filep); 235
230// llinfos << "LLLFSThread::WRITE:" << mFileName << " Bytes: " << mBytesRead << "/" << mBytes << " Offset:" << mOffset << llendl; 236// llinfos << "LLLFSThread::WRITE:" << mFileName << " Bytes: " << mBytesRead << "/" << mBytes << " Offset:" << mOffset << llendl;
231 } 237 }
232 else 238 else