diff options
author | Jacek Antonelli | 2010-02-08 17:01:00 -0600 |
---|---|---|
committer | Jacek Antonelli | 2010-02-08 17:01:00 -0600 |
commit | d96e672c7fa0cb59ef0c30163326bb40220e745a (patch) | |
tree | 0578f6258788f44f91dbf84eebdb09d994e2a0e5 | |
parent | Fixed login screen only allowing 16 chars per name. (diff) | |
download | meta-impy-d96e672c7fa0cb59ef0c30163326bb40220e745a.zip meta-impy-d96e672c7fa0cb59ef0c30163326bb40220e745a.tar.gz meta-impy-d96e672c7fa0cb59ef0c30163326bb40220e745a.tar.bz2 meta-impy-d96e672c7fa0cb59ef0c30163326bb40220e745a.tar.xz |
Ported many APR changes from Snowglobe.
21 files changed, 257 insertions, 251 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 66e848c..46f37cb 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt | |||
@@ -1,3 +1,29 @@ | |||
1 | 2010-02-08 Jacek Antonelli <jacek.antonelli@gmail.com> | ||
2 | |||
3 | * Ported many APR changes from Snowglobe. | ||
4 | |||
5 | modified: linden/indra/llaudio/vorbisencode.cpp | ||
6 | modified: linden/indra/llcharacter/llbvhloader.cpp | ||
7 | modified: linden/indra/llcharacter/llkeyframemotionparam.cpp | ||
8 | modified: linden/indra/llcharacter/llstatemachine.cpp | ||
9 | modified: linden/indra/llcommon/llapr.cpp | ||
10 | modified: linden/indra/llcommon/llapr.h | ||
11 | modified: linden/indra/llcommon/llthread.cpp | ||
12 | modified: linden/indra/llcommon/llthread.h | ||
13 | modified: linden/indra/llcommon/llworkerthread.cpp | ||
14 | modified: linden/indra/llimage/llimage.cpp | ||
15 | modified: linden/indra/llimage/llimagej2c.cpp | ||
16 | modified: linden/indra/llmessage/llcurl.cpp | ||
17 | modified: linden/indra/llvfs/lllfsthread.cpp | ||
18 | modified: linden/indra/llvfs/llvfs.cpp | ||
19 | modified: linden/indra/newview/llappviewer.cpp | ||
20 | modified: linden/indra/newview/llfloateranimpreview.cpp | ||
21 | modified: linden/indra/newview/lltexturecache.cpp | ||
22 | modified: linden/indra/newview/llviewermenufile.cpp | ||
23 | modified: linden/indra/newview/llvoavatar.cpp | ||
24 | modified: linden/indra/newview/primbackup.cpp | ||
25 | |||
26 | |||
1 | 2010-02-07 Jacek Antonelli <jacek.antonelli@gmail.com> | 27 | 2010-02-07 Jacek Antonelli <jacek.antonelli@gmail.com> |
2 | 28 | ||
3 | * Fixed login screen only allowing 16 chars per name. | 29 | * Fixed login screen only allowing 16 chars per name. |
diff --git a/linden/indra/llaudio/vorbisencode.cpp b/linden/indra/llaudio/vorbisencode.cpp index 7df1416..57e7724 100644 --- a/linden/indra/llaudio/vorbisencode.cpp +++ b/linden/indra/llaudio/vorbisencode.cpp | |||
@@ -88,7 +88,7 @@ S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& erro | |||
88 | 88 | ||
89 | //******************************** | 89 | //******************************** |
90 | LLAPRFile infile ; | 90 | LLAPRFile infile ; |
91 | infile.open(in_fname,LL_APR_RB); | 91 | infile.open(in_fname,LL_APR_RB, LLAPRFile::global); |
92 | //******************************** | 92 | //******************************** |
93 | if (!infile.getFileHandle()) | 93 | if (!infile.getFileHandle()) |
94 | { | 94 | { |
@@ -232,7 +232,7 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname | |||
232 | S32 data_left = 0; | 232 | S32 data_left = 0; |
233 | 233 | ||
234 | LLAPRFile infile ; | 234 | LLAPRFile infile ; |
235 | infile.open(in_fname,LL_APR_RB); | 235 | infile.open(in_fname,LL_APR_RB, LLAPRFile::global); |
236 | if (!infile.getFileHandle()) | 236 | if (!infile.getFileHandle()) |
237 | { | 237 | { |
238 | llwarns << "Couldn't open temporary ogg file for writing: " << in_fname | 238 | llwarns << "Couldn't open temporary ogg file for writing: " << in_fname |
@@ -241,7 +241,7 @@ S32 encode_vorbis_file(const std::string& in_fname, const std::string& out_fname | |||
241 | } | 241 | } |
242 | 242 | ||
243 | LLAPRFile outfile ; | 243 | LLAPRFile outfile ; |
244 | outfile.open(out_fname,LL_APR_WPB); | 244 | outfile.open(out_fname,LL_APR_WPB, LLAPRFile::global); |
245 | if (!outfile.getFileHandle()) | 245 | if (!outfile.getFileHandle()) |
246 | { | 246 | { |
247 | llwarns << "Couldn't open upload sound file for reading: " << in_fname | 247 | llwarns << "Couldn't open upload sound file for reading: " << in_fname |
diff --git a/linden/indra/llcharacter/llbvhloader.cpp b/linden/indra/llcharacter/llbvhloader.cpp index e1f8ce5..49b6d82 100644 --- a/linden/indra/llcharacter/llbvhloader.cpp +++ b/linden/indra/llcharacter/llbvhloader.cpp | |||
@@ -179,7 +179,7 @@ LLBVHLoader::Status LLBVHLoader::loadTranslationTable(const char *fileName) | |||
179 | std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName); | 179 | std::string path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,fileName); |
180 | 180 | ||
181 | LLAPRFile infile ; | 181 | LLAPRFile infile ; |
182 | infile.open(path, LL_APR_R); | 182 | infile.open(path, LL_APR_R, LLAPRFile::global); |
183 | apr_file_t *fp = infile.getFileHandle(); | 183 | apr_file_t *fp = infile.getFileHandle(); |
184 | if (!fp) | 184 | if (!fp) |
185 | return ST_NO_XLT_FILE; | 185 | return ST_NO_XLT_FILE; |
diff --git a/linden/indra/llcharacter/llkeyframemotionparam.cpp b/linden/indra/llcharacter/llkeyframemotionparam.cpp index a9c1f6f..3692bf6 100644 --- a/linden/indra/llcharacter/llkeyframemotionparam.cpp +++ b/linden/indra/llcharacter/llkeyframemotionparam.cpp | |||
@@ -355,7 +355,7 @@ BOOL LLKeyframeMotionParam::loadMotions() | |||
355 | //------------------------------------------------------------------------- | 355 | //------------------------------------------------------------------------- |
356 | S32 fileSize = 0; | 356 | S32 fileSize = 0; |
357 | LLAPRFile infile ; | 357 | LLAPRFile infile ; |
358 | infile.open(path, LL_APR_R, NULL, &fileSize); | 358 | infile.open(path, LL_APR_R, LLAPRFile::global, &fileSize); |
359 | apr_file_t* fp = infile.getFileHandle() ; | 359 | apr_file_t* fp = infile.getFileHandle() ; |
360 | if (!fp || fileSize == 0) | 360 | if (!fp || fileSize == 0) |
361 | { | 361 | { |
diff --git a/linden/indra/llcharacter/llstatemachine.cpp b/linden/indra/llcharacter/llstatemachine.cpp index 73c6951..71e2eaa 100644 --- a/linden/indra/llcharacter/llstatemachine.cpp +++ b/linden/indra/llcharacter/llstatemachine.cpp | |||
@@ -210,7 +210,7 @@ LLFSMState* LLStateDiagram::getState(U32 state_id) | |||
210 | BOOL LLStateDiagram::saveDotFile(const std::string& filename) | 210 | BOOL LLStateDiagram::saveDotFile(const std::string& filename) |
211 | { | 211 | { |
212 | LLAPRFile outfile ; | 212 | LLAPRFile outfile ; |
213 | outfile.open(filename, LL_APR_W); | 213 | outfile.open(filename, LL_APR_W, LLAPRFile::global); |
214 | apr_file_t* dot_file = outfile.getFileHandle() ; | 214 | apr_file_t* dot_file = outfile.getFileHandle() ; |
215 | 215 | ||
216 | if (!dot_file) | 216 | if (!dot_file) |
diff --git a/linden/indra/llcommon/llapr.cpp b/linden/indra/llcommon/llapr.cpp index 669afc5..7e3a26c 100644 --- a/linden/indra/llcommon/llapr.cpp +++ b/linden/indra/llcommon/llapr.cpp | |||
@@ -36,7 +36,6 @@ | |||
36 | #include "llapr.h" | 36 | #include "llapr.h" |
37 | 37 | ||
38 | apr_pool_t *gAPRPoolp = NULL; // Global APR memory pool | 38 | apr_pool_t *gAPRPoolp = NULL; // Global APR memory pool |
39 | LLVolatileAPRPool *LLAPRFile::sAPRFilePoolp = NULL ; //global volatile APR memory pool. | ||
40 | apr_thread_mutex_t *gLogMutexp = NULL; | 39 | apr_thread_mutex_t *gLogMutexp = NULL; |
41 | apr_thread_mutex_t *gCallStacksLogMutexp = NULL; | 40 | apr_thread_mutex_t *gCallStacksLogMutexp = NULL; |
42 | 41 | ||
@@ -53,11 +52,9 @@ void ll_init_apr() | |||
53 | // Initialize the logging mutex | 52 | // Initialize the logging mutex |
54 | apr_thread_mutex_create(&gLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp); | 53 | apr_thread_mutex_create(&gLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp); |
55 | apr_thread_mutex_create(&gCallStacksLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp); | 54 | apr_thread_mutex_create(&gCallStacksLogMutexp, APR_THREAD_MUTEX_UNNESTED, gAPRPoolp); |
56 | } | ||
57 | 55 | ||
58 | if(!LLAPRFile::sAPRFilePoolp) | 56 | // Initialize thread-local APR pool support. |
59 | { | 57 | LLVolatileAPRPool::initLocalAPRFilePool(); |
60 | LLAPRFile::sAPRFilePoolp = new LLVolatileAPRPool() ; | ||
61 | } | 58 | } |
62 | } | 59 | } |
63 | 60 | ||
@@ -87,11 +84,6 @@ void ll_cleanup_apr() | |||
87 | apr_pool_destroy(gAPRPoolp); | 84 | apr_pool_destroy(gAPRPoolp); |
88 | gAPRPoolp = NULL; | 85 | gAPRPoolp = NULL; |
89 | } | 86 | } |
90 | if (LLAPRFile::sAPRFilePoolp) | ||
91 | { | ||
92 | delete LLAPRFile::sAPRFilePoolp ; | ||
93 | LLAPRFile::sAPRFilePoolp = NULL ; | ||
94 | } | ||
95 | apr_terminate(); | 87 | apr_terminate(); |
96 | } | 88 | } |
97 | 89 | ||
@@ -207,6 +199,56 @@ BOOL LLVolatileAPRPool::isFull() | |||
207 | { | 199 | { |
208 | return mNumTotalRef > FULL_VOLATILE_APR_POOL ; | 200 | return mNumTotalRef > FULL_VOLATILE_APR_POOL ; |
209 | } | 201 | } |
202 | |||
203 | #ifdef SHOW_ASSERT | ||
204 | // This allows the use of llassert(is_main_thread()) to assure the current thread is the main thread. | ||
205 | static void* gIsMainThread; | ||
206 | bool is_main_thread() { return gIsMainThread == LLVolatileAPRPool::getLocalAPRFilePool(); } | ||
207 | #endif | ||
208 | |||
209 | // The thread private handle to access the LocalAPRFilePool. | ||
210 | apr_threadkey_t* LLVolatileAPRPool::sLocalAPRFilePoolKey; | ||
211 | |||
212 | // This should be called exactly once, before the first call to createLocalAPRFilePool. | ||
213 | // static | ||
214 | void LLVolatileAPRPool::initLocalAPRFilePool() | ||
215 | { | ||
216 | apr_status_t status = apr_threadkey_private_create(&sLocalAPRFilePoolKey, &destroyLocalAPRFilePool, gAPRPoolp); | ||
217 | ll_apr_assert_status(status); // Or out of memory, or system-imposed limit on the | ||
218 | // total number of keys per process {PTHREAD_KEYS_MAX} | ||
219 | // has been exceeded. | ||
220 | // Create the thread-local pool for the main thread (this function is called by the main thread). | ||
221 | createLocalAPRFilePool(); | ||
222 | #ifdef SHOW_ASSERT | ||
223 | gIsMainThread = getLocalAPRFilePool(); | ||
224 | #endif | ||
225 | } | ||
226 | |||
227 | // This should be called once for every thread, before it uses getLocalAPRFilePool. | ||
228 | // static | ||
229 | void LLVolatileAPRPool::createLocalAPRFilePool() | ||
230 | { | ||
231 | void* thread_local_data = new LLVolatileAPRPool; | ||
232 | apr_status_t status = apr_threadkey_private_set(thread_local_data, sLocalAPRFilePoolKey); | ||
233 | llassert_always(status == APR_SUCCESS); | ||
234 | } | ||
235 | |||
236 | // This is called once for every thread when the thread is destructed. | ||
237 | // static | ||
238 | void LLVolatileAPRPool::destroyLocalAPRFilePool(void* thread_local_data) | ||
239 | { | ||
240 | delete reinterpret_cast<LLVolatileAPRPool*>(thread_local_data); | ||
241 | } | ||
242 | |||
243 | // static | ||
244 | LLVolatileAPRPool* LLVolatileAPRPool::getLocalAPRFilePool() | ||
245 | { | ||
246 | void* thread_local_data; | ||
247 | apr_status_t status = apr_threadkey_private_get(&thread_local_data, sLocalAPRFilePoolKey); | ||
248 | llassert_always(status == APR_SUCCESS); | ||
249 | return reinterpret_cast<LLVolatileAPRPool*>(thread_local_data); | ||
250 | } | ||
251 | |||
210 | //--------------------------------------------------------------------- | 252 | //--------------------------------------------------------------------- |
211 | // | 253 | // |
212 | // LLScopedLock | 254 | // LLScopedLock |
@@ -251,10 +293,9 @@ void LLScopedLock::unlock() | |||
251 | bool ll_apr_warn_status(apr_status_t status) | 293 | bool ll_apr_warn_status(apr_status_t status) |
252 | { | 294 | { |
253 | if(APR_SUCCESS == status) return false; | 295 | if(APR_SUCCESS == status) return false; |
254 | #ifndef LL_WINDOWS | ||
255 | char buf[MAX_STRING]; /* Flawfinder: ignore */ | 296 | char buf[MAX_STRING]; /* Flawfinder: ignore */ |
256 | LL_WARNS_ONCE("APR") << "APR: " << apr_strerror(status, buf, MAX_STRING) << LL_ENDL; | 297 | apr_strerror(status, buf, MAX_STRING); |
257 | #endif | 298 | LL_WARNS("APR") << "APR: " << buf << LL_ENDL; |
258 | return true; | 299 | return true; |
259 | } | 300 | } |
260 | 301 | ||
@@ -268,10 +309,18 @@ void ll_apr_assert_status(apr_status_t status) | |||
268 | // LLAPRFile functions | 309 | // LLAPRFile functions |
269 | // | 310 | // |
270 | LLAPRFile::LLAPRFile() | 311 | LLAPRFile::LLAPRFile() |
312 | : mFile(NULL), | ||
313 | mCurrentFilePoolp(NULL) | ||
271 | { | 314 | { |
272 | mFile = NULL ; | ||
273 | mCurrentFilePoolp = NULL ; | ||
274 | } | 315 | } |
316 | |||
317 | LLAPRFile::LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type) | ||
318 | : mFile(NULL), | ||
319 | mCurrentFilePoolp(NULL) | ||
320 | { | ||
321 | open(filename, flags, access_type); | ||
322 | } | ||
323 | |||
275 | LLAPRFile::~LLAPRFile() | 324 | LLAPRFile::~LLAPRFile() |
276 | { | 325 | { |
277 | close() ; | 326 | close() ; |
@@ -295,32 +344,27 @@ apr_status_t LLAPRFile::close() | |||
295 | return ret ; | 344 | return ret ; |
296 | } | 345 | } |
297 | 346 | ||
298 | apr_status_t LLAPRFile::open(LLVolatileAPRPool* pool, const std::string& filename, apr_int32_t flags, S32* sizep) | 347 | apr_status_t LLAPRFile::open(std::string const& filename, apr_int32_t flags, access_t access_type, S32* sizep) |
299 | { | 348 | { |
300 | apr_status_t s ; | 349 | llassert_always(!mFile); |
301 | s = open(filename, flags, pool ? pool->getVolatileAPRPool() : NULL, sizep) ; | 350 | llassert_always(!mCurrentFilePoolp); |
302 | |||
303 | if(!mCurrentFilePoolp) | ||
304 | { | ||
305 | mCurrentFilePoolp = pool ; | ||
306 | 351 | ||
307 | if(!mFile) | 352 | // Access the pool and increment it's reference count. |
308 | { | 353 | // The reference count of LLVolatileAPRPool objects will be decremented |
309 | close() ; | 354 | // again in LLAPRFile::close by calling mCurrentFilePoolp->clearVolatileAPRPool(). |
310 | } | 355 | apr_pool_t* pool; |
356 | if (access_type == local) | ||
357 | { | ||
358 | // Use a "volatile" thread-local pool. | ||
359 | mCurrentFilePoolp = LLVolatileAPRPool::getLocalAPRFilePool(); | ||
360 | pool = mCurrentFilePoolp->getVolatileAPRPool(); | ||
311 | } | 361 | } |
312 | 362 | else | |
313 | return s ; | 363 | { |
314 | } | 364 | llassert(is_main_thread()); |
315 | apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, apr_pool_t* pool, S32* sizep) | 365 | pool = gAPRPoolp; |
316 | { | 366 | } |
317 | apr_status_t s; | 367 | apr_status_t s = apr_file_open(&mFile, filename.c_str(), flags, APR_OS_DEFAULT, pool); |
318 | |||
319 | //check if already open some file | ||
320 | llassert_always(!mFile) ; | ||
321 | llassert_always(!mCurrentFilePoolp) ; | ||
322 | |||
323 | s = apr_file_open(&mFile, filename.c_str(), flags, APR_OS_DEFAULT, getAPRFilePool(pool)); | ||
324 | if (s != APR_SUCCESS || !mFile) | 368 | if (s != APR_SUCCESS || !mFile) |
325 | { | 369 | { |
326 | mFile = NULL ; | 370 | mFile = NULL ; |
@@ -349,17 +393,6 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, apr | |||
349 | return s; | 393 | return s; |
350 | } | 394 | } |
351 | 395 | ||
352 | apr_pool_t* LLAPRFile::getAPRFilePool(apr_pool_t* pool) | ||
353 | { | ||
354 | if(!pool) | ||
355 | { | ||
356 | mCurrentFilePoolp = sAPRFilePoolp ; | ||
357 | return mCurrentFilePoolp->getVolatileAPRPool() ; | ||
358 | } | ||
359 | |||
360 | return pool ; | ||
361 | } | ||
362 | |||
363 | // File I/O | 396 | // File I/O |
364 | S32 LLAPRFile::read(void *buf, S32 nbytes) | 397 | S32 LLAPRFile::read(void *buf, S32 nbytes) |
365 | { | 398 | { |
@@ -369,6 +402,7 @@ S32 LLAPRFile::read(void *buf, S32 nbytes) | |||
369 | apr_status_t s = apr_file_read(mFile, buf, &sz); | 402 | apr_status_t s = apr_file_read(mFile, buf, &sz); |
370 | if (s != APR_SUCCESS) | 403 | if (s != APR_SUCCESS) |
371 | { | 404 | { |
405 | ll_apr_warn_status(s); | ||
372 | return 0; | 406 | return 0; |
373 | } | 407 | } |
374 | else | 408 | else |
@@ -386,6 +420,7 @@ S32 LLAPRFile::write(const void *buf, S32 nbytes) | |||
386 | apr_status_t s = apr_file_write(mFile, buf, &sz); | 420 | apr_status_t s = apr_file_write(mFile, buf, &sz); |
387 | if (s != APR_SUCCESS) | 421 | if (s != APR_SUCCESS) |
388 | { | 422 | { |
423 | ll_apr_warn_status(s); | ||
389 | return 0; | 424 | return 0; |
390 | } | 425 | } |
391 | else | 426 | else |
@@ -405,42 +440,16 @@ S32 LLAPRFile::seek(apr_seek_where_t where, S32 offset) | |||
405 | //static components of LLAPRFile | 440 | //static components of LLAPRFile |
406 | // | 441 | // |
407 | 442 | ||
408 | //static | 443 | // Used in the static functions below. |
409 | apr_status_t LLAPRFile::close(apr_file_t* file_handle, LLVolatileAPRPool* pool) | 444 | class LLScopedVolatileAPRFilePool { |
410 | { | 445 | private: |
411 | apr_status_t ret = APR_SUCCESS ; | 446 | LLVolatileAPRPool* mPool; |
412 | if(file_handle) | 447 | apr_pool_t* apr_pool; |
413 | { | 448 | public: |
414 | ret = apr_file_close(file_handle); | 449 | LLScopedVolatileAPRFilePool() : mPool(LLVolatileAPRPool::getLocalAPRFilePool()), apr_pool(mPool->getVolatileAPRPool()) { } |
415 | file_handle = NULL ; | 450 | ~LLScopedVolatileAPRFilePool() { mPool->clearVolatileAPRPool(); } |
416 | } | 451 | operator apr_pool_t*() const { return apr_pool; } |
417 | 452 | }; | |
418 | if(pool) | ||
419 | { | ||
420 | pool->clearVolatileAPRPool() ; | ||
421 | } | ||
422 | |||
423 | return ret ; | ||
424 | } | ||
425 | |||
426 | //static | ||
427 | apr_file_t* LLAPRFile::open(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags) | ||
428 | { | ||
429 | apr_status_t s; | ||
430 | apr_file_t* file_handle ; | ||
431 | |||
432 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | ||
433 | |||
434 | s = apr_file_open(&file_handle, filename.c_str(), flags, APR_OS_DEFAULT, pool->getVolatileAPRPool()); | ||
435 | if (s != APR_SUCCESS || !file_handle) | ||
436 | { | ||
437 | file_handle = NULL ; | ||
438 | close(file_handle, pool) ; | ||
439 | return NULL; | ||
440 | } | ||
441 | |||
442 | return file_handle ; | ||
443 | } | ||
444 | 453 | ||
445 | //static | 454 | //static |
446 | S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) | 455 | S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) |
@@ -464,6 +473,7 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) | |||
464 | } | 473 | } |
465 | if (s != APR_SUCCESS) | 474 | if (s != APR_SUCCESS) |
466 | { | 475 | { |
476 | ll_apr_warn_status(s); | ||
467 | return -1; | 477 | return -1; |
468 | } | 478 | } |
469 | else | 479 | else |
@@ -474,13 +484,15 @@ S32 LLAPRFile::seek(apr_file_t* file_handle, apr_seek_where_t where, S32 offset) | |||
474 | } | 484 | } |
475 | 485 | ||
476 | //static | 486 | //static |
477 | S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) | 487 | S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes) |
478 | { | 488 | { |
479 | //***************************************** | 489 | apr_file_t* file_handle; |
480 | apr_file_t* file_handle = open(filename, pool, APR_READ|APR_BINARY); | 490 | LLScopedVolatileAPRFilePool pool; |
481 | //***************************************** | 491 | apr_status_t s = apr_file_open(&file_handle, filename.c_str(), APR_READ|APR_BINARY, APR_OS_DEFAULT, pool); |
482 | if (!file_handle) | 492 | if (s != APR_SUCCESS || !file_handle) |
483 | { | 493 | { |
494 | ll_apr_warn_status(s); | ||
495 | LL_WARNS("APR") << " while attempting to open file \"" << filename << '"' << LL_ENDL; | ||
484 | return 0; | 496 | return 0; |
485 | } | 497 | } |
486 | 498 | ||
@@ -501,6 +513,8 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb | |||
501 | apr_status_t s = apr_file_read(file_handle, buf, &bytes_read); | 513 | apr_status_t s = apr_file_read(file_handle, buf, &bytes_read); |
502 | if (s != APR_SUCCESS) | 514 | if (s != APR_SUCCESS) |
503 | { | 515 | { |
516 | LL_WARNS("APR") << " Attempting to read filename: " << filename << LL_ENDL; | ||
517 | ll_apr_warn_status(s); | ||
504 | bytes_read = 0; | 518 | bytes_read = 0; |
505 | } | 519 | } |
506 | else | 520 | else |
@@ -509,14 +523,13 @@ S32 LLAPRFile::readEx(const std::string& filename, void *buf, S32 offset, S32 nb | |||
509 | } | 523 | } |
510 | } | 524 | } |
511 | 525 | ||
512 | //***************************************** | 526 | apr_file_close(file_handle); |
513 | close(file_handle, pool) ; | 527 | |
514 | //***************************************** | ||
515 | return (S32)bytes_read; | 528 | return (S32)bytes_read; |
516 | } | 529 | } |
517 | 530 | ||
518 | //static | 531 | //static |
519 | S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool) | 532 | S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes) |
520 | { | 533 | { |
521 | apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; | 534 | apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; |
522 | if (offset < 0) | 535 | if (offset < 0) |
@@ -525,11 +538,13 @@ S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 n | |||
525 | offset = 0; | 538 | offset = 0; |
526 | } | 539 | } |
527 | 540 | ||
528 | //***************************************** | 541 | apr_file_t* file_handle; |
529 | apr_file_t* file_handle = open(filename, pool, flags); | 542 | LLScopedVolatileAPRFilePool pool; |
530 | //***************************************** | 543 | apr_status_t s = apr_file_open(&file_handle, filename.c_str(), flags, APR_OS_DEFAULT, pool); |
531 | if (!file_handle) | 544 | if (s != APR_SUCCESS || !file_handle) |
532 | { | 545 | { |
546 | ll_apr_warn_status(s); | ||
547 | LL_WARNS("APR") << " while attempting to open file \"" << filename << '"' << LL_ENDL; | ||
533 | return 0; | 548 | return 0; |
534 | } | 549 | } |
535 | 550 | ||
@@ -549,6 +564,8 @@ S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 n | |||
549 | apr_status_t s = apr_file_write(file_handle, buf, &bytes_written); | 564 | apr_status_t s = apr_file_write(file_handle, buf, &bytes_written); |
550 | if (s != APR_SUCCESS) | 565 | if (s != APR_SUCCESS) |
551 | { | 566 | { |
567 | LL_WARNS("APR") << " Attempting to write filename: " << filename << LL_ENDL; | ||
568 | ll_apr_warn_status(s); | ||
552 | bytes_written = 0; | 569 | bytes_written = 0; |
553 | } | 570 | } |
554 | else | 571 | else |
@@ -557,93 +574,84 @@ S32 LLAPRFile::writeEx(const std::string& filename, void *buf, S32 offset, S32 n | |||
557 | } | 574 | } |
558 | } | 575 | } |
559 | 576 | ||
560 | //***************************************** | 577 | apr_file_close(file_handle); |
561 | LLAPRFile::close(file_handle, pool); | ||
562 | //***************************************** | ||
563 | 578 | ||
564 | return (S32)bytes_written; | 579 | return (S32)bytes_written; |
565 | } | 580 | } |
566 | 581 | ||
567 | //static | 582 | //static |
568 | bool LLAPRFile::remove(const std::string& filename, LLVolatileAPRPool* pool) | 583 | bool LLAPRFile::remove(const std::string& filename) |
569 | { | 584 | { |
570 | apr_status_t s; | 585 | apr_status_t s; |
571 | 586 | ||
572 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | 587 | LLScopedVolatileAPRFilePool pool; |
573 | s = apr_file_remove(filename.c_str(), pool->getVolatileAPRPool()); | 588 | s = apr_file_remove(filename.c_str(), pool); |
574 | pool->clearVolatileAPRPool() ; | ||
575 | 589 | ||
576 | if (s != APR_SUCCESS) | 590 | if (s != APR_SUCCESS) |
577 | { | 591 | { |
578 | LL_DEBUGS("APR") << "LLAPRFile::remove failed on file: " << filename << LL_ENDL; | ||
579 | ll_apr_warn_status(s); | 592 | ll_apr_warn_status(s); |
593 | LL_WARNS("APR") << " Attempting to remove filename: " << filename << LL_ENDL; | ||
580 | return false; | 594 | return false; |
581 | } | 595 | } |
582 | return true; | 596 | return true; |
583 | } | 597 | } |
584 | 598 | ||
585 | //static | 599 | //static |
586 | bool LLAPRFile::rename(const std::string& filename, const std::string& newname, LLVolatileAPRPool* pool) | 600 | bool LLAPRFile::rename(const std::string& filename, const std::string& newname) |
587 | { | 601 | { |
588 | apr_status_t s; | 602 | apr_status_t s; |
589 | 603 | ||
590 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | 604 | LLScopedVolatileAPRFilePool pool; |
591 | s = apr_file_rename(filename.c_str(), newname.c_str(), pool->getVolatileAPRPool()); | 605 | s = apr_file_rename(filename.c_str(), newname.c_str(), pool); |
592 | pool->clearVolatileAPRPool() ; | ||
593 | 606 | ||
594 | if (s != APR_SUCCESS) | 607 | if (s != APR_SUCCESS) |
595 | { | 608 | { |
596 | LL_DEBUGS("APR") << "LLAPRFile::rename failed on file: " << filename << LL_ENDL; | ||
597 | ll_apr_warn_status(s); | 609 | ll_apr_warn_status(s); |
610 | LL_WARNS("APR") << " Attempting to rename filename: " << filename << LL_ENDL; | ||
598 | return false; | 611 | return false; |
599 | } | 612 | } |
600 | return true; | 613 | return true; |
601 | } | 614 | } |
602 | 615 | ||
603 | //static | 616 | //static |
604 | bool LLAPRFile::isExist(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags) | 617 | bool LLAPRFile::isExist(const std::string& filename, apr_int32_t flags) |
605 | { | 618 | { |
606 | apr_file_t* apr_file; | 619 | apr_file_t* file_handle; |
607 | apr_status_t s; | 620 | apr_status_t s; |
608 | 621 | ||
609 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | 622 | LLScopedVolatileAPRFilePool pool; |
610 | s = apr_file_open(&apr_file, filename.c_str(), flags, APR_OS_DEFAULT, pool->getVolatileAPRPool()); | 623 | s = apr_file_open(&file_handle, filename.c_str(), flags, APR_OS_DEFAULT, pool); |
611 | 624 | ||
612 | if (s != APR_SUCCESS || !apr_file) | 625 | if (s != APR_SUCCESS || !file_handle) |
613 | { | 626 | { |
614 | pool->clearVolatileAPRPool() ; | ||
615 | return false; | 627 | return false; |
616 | } | 628 | } |
617 | else | 629 | else |
618 | { | 630 | { |
619 | apr_file_close(apr_file) ; | 631 | apr_file_close(file_handle); |
620 | pool->clearVolatileAPRPool() ; | ||
621 | return true; | 632 | return true; |
622 | } | 633 | } |
623 | } | 634 | } |
624 | 635 | ||
625 | //static | 636 | //static |
626 | S32 LLAPRFile::size(const std::string& filename, LLVolatileAPRPool* pool) | 637 | S32 LLAPRFile::size(const std::string& filename) |
627 | { | 638 | { |
628 | apr_file_t* apr_file; | 639 | apr_file_t* file_handle; |
629 | apr_finfo_t info; | 640 | apr_finfo_t info; |
630 | apr_status_t s; | 641 | apr_status_t s; |
631 | 642 | ||
632 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | 643 | LLScopedVolatileAPRFilePool pool; |
633 | s = apr_file_open(&apr_file, filename.c_str(), APR_READ, APR_OS_DEFAULT, pool->getVolatileAPRPool()); | 644 | s = apr_file_open(&file_handle, filename.c_str(), APR_READ, APR_OS_DEFAULT, pool); |
634 | 645 | ||
635 | if (s != APR_SUCCESS || !apr_file) | 646 | if (s != APR_SUCCESS || !file_handle) |
636 | { | 647 | { |
637 | pool->clearVolatileAPRPool() ; | ||
638 | |||
639 | return 0; | 648 | return 0; |
640 | } | 649 | } |
641 | else | 650 | else |
642 | { | 651 | { |
643 | apr_status_t s = apr_file_info_get(&info, APR_FINFO_SIZE, apr_file); | 652 | apr_status_t s = apr_file_info_get(&info, APR_FINFO_SIZE, file_handle); |
644 | 653 | ||
645 | apr_file_close(apr_file) ; | 654 | apr_file_close(file_handle) ; |
646 | pool->clearVolatileAPRPool() ; | ||
647 | 655 | ||
648 | if (s == APR_SUCCESS) | 656 | if (s == APR_SUCCESS) |
649 | { | 657 | { |
@@ -657,36 +665,34 @@ S32 LLAPRFile::size(const std::string& filename, LLVolatileAPRPool* pool) | |||
657 | } | 665 | } |
658 | 666 | ||
659 | //static | 667 | //static |
660 | bool LLAPRFile::makeDir(const std::string& dirname, LLVolatileAPRPool* pool) | 668 | bool LLAPRFile::makeDir(const std::string& dirname) |
661 | { | 669 | { |
662 | apr_status_t s; | 670 | apr_status_t s; |
663 | 671 | ||
664 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | 672 | LLScopedVolatileAPRFilePool pool; |
665 | s = apr_dir_make(dirname.c_str(), APR_FPROT_OS_DEFAULT, pool->getVolatileAPRPool()); | 673 | s = apr_dir_make(dirname.c_str(), APR_FPROT_OS_DEFAULT, pool); |
666 | pool->clearVolatileAPRPool() ; | ||
667 | 674 | ||
668 | if (s != APR_SUCCESS) | 675 | if (s != APR_SUCCESS) |
669 | { | 676 | { |
670 | LL_DEBUGS("APR") << "LLAPRFile::makeDir failed on file: " << dirname << LL_ENDL; | ||
671 | ll_apr_warn_status(s); | 677 | ll_apr_warn_status(s); |
678 | LL_WARNS("APR") << " while attempting to make directory: " << dirname << LL_ENDL; | ||
672 | return false; | 679 | return false; |
673 | } | 680 | } |
674 | return true; | 681 | return true; |
675 | } | 682 | } |
676 | 683 | ||
677 | //static | 684 | //static |
678 | bool LLAPRFile::removeDir(const std::string& dirname, LLVolatileAPRPool* pool) | 685 | bool LLAPRFile::removeDir(const std::string& dirname) |
679 | { | 686 | { |
680 | apr_status_t s; | 687 | apr_status_t s; |
681 | 688 | ||
682 | pool = pool ? pool : LLAPRFile::sAPRFilePoolp ; | 689 | LLScopedVolatileAPRFilePool pool; |
683 | s = apr_file_remove(dirname.c_str(), pool->getVolatileAPRPool()); | 690 | s = apr_file_remove(dirname.c_str(), pool); |
684 | pool->clearVolatileAPRPool() ; | ||
685 | 691 | ||
686 | if (s != APR_SUCCESS) | 692 | if (s != APR_SUCCESS) |
687 | { | 693 | { |
688 | LL_DEBUGS("APR") << "LLAPRFile::removeDir failed on file: " << dirname << LL_ENDL; | ||
689 | ll_apr_warn_status(s); | 694 | ll_apr_warn_status(s); |
695 | LL_WARNS("APR") << " Attempting to remove directory: " << dirname << LL_ENDL; | ||
690 | return false; | 696 | return false; |
691 | } | 697 | } |
692 | return true; | 698 | return true; |
diff --git a/linden/indra/llcommon/llapr.h b/linden/indra/llcommon/llapr.h index 63130a8..7f770b0 100644 --- a/linden/indra/llcommon/llapr.h +++ b/linden/indra/llcommon/llapr.h | |||
@@ -92,7 +92,7 @@ protected: | |||
92 | //which clears memory automatically. | 92 | //which clears memory automatically. |
93 | //so it can not hold static data or data after memory is cleared | 93 | //so it can not hold static data or data after memory is cleared |
94 | // | 94 | // |
95 | class LLVolatileAPRPool : public LLAPRPool | 95 | class LLVolatileAPRPool : protected LLAPRPool |
96 | { | 96 | { |
97 | public: | 97 | public: |
98 | LLVolatileAPRPool(apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE); | 98 | LLVolatileAPRPool(apr_pool_t *parent = NULL, apr_size_t size = 0, BOOL releasePoolFlag = TRUE); |
@@ -104,9 +104,17 @@ public: | |||
104 | 104 | ||
105 | BOOL isFull() ; | 105 | BOOL isFull() ; |
106 | BOOL isEmpty() {return !mNumActiveRef ;} | 106 | BOOL isEmpty() {return !mNumActiveRef ;} |
107 | |||
108 | static void initLocalAPRFilePool(); | ||
109 | static void createLocalAPRFilePool(); | ||
110 | static void destroyLocalAPRFilePool(void* thread_local_data); | ||
111 | static LLVolatileAPRPool* getLocalAPRFilePool(); | ||
112 | |||
107 | private: | 113 | private: |
108 | S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool. | 114 | S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool. |
109 | S32 mNumTotalRef ; //number of total pointers pointing to the apr_pool since last creating. | 115 | S32 mNumTotalRef ; //number of total pointers pointing to the apr_pool since last creating. |
116 | |||
117 | static apr_threadkey_t* sLocalAPRFilePoolKey; | ||
110 | } ; | 118 | } ; |
111 | 119 | ||
112 | /** | 120 | /** |
@@ -192,18 +200,25 @@ typedef LLAtomic32<S32> LLAtomicS32; | |||
192 | // 1, a temperary pool passed to an APRFile function, which is used within this function and only once. | 200 | // 1, a temperary pool passed to an APRFile function, which is used within this function and only once. |
193 | // 2, a global pool. | 201 | // 2, a global pool. |
194 | // | 202 | // |
195 | class LLAPRFile | 203 | |
204 | class LLAPRFile : boost::noncopyable | ||
196 | { | 205 | { |
206 | // make this non copyable since a copy closes the file | ||
197 | private: | 207 | private: |
198 | apr_file_t* mFile ; | 208 | apr_file_t* mFile ; |
199 | LLVolatileAPRPool *mCurrentFilePoolp ; //currently in use apr_pool, could be one of them: sAPRFilePoolp, or a temp pool. | 209 | LLVolatileAPRPool *mCurrentFilePoolp ; //currently in use apr_pool, could be one of them: sAPRFilePoolp, or a temp pool. |
200 | 210 | ||
201 | public: | 211 | public: |
212 | enum access_t { | ||
213 | global, // Use a global pool for long-lived file accesses. This should really only happen from the main thread. | ||
214 | local // Use a thread-local volatile pool for short file accesses. | ||
215 | }; | ||
216 | |||
202 | LLAPRFile() ; | 217 | LLAPRFile() ; |
218 | LLAPRFile(const std::string& filename, apr_int32_t flags, access_t access_type); | ||
203 | ~LLAPRFile() ; | 219 | ~LLAPRFile() ; |
204 | 220 | ||
205 | apr_status_t open(LLVolatileAPRPool* pool, const std::string& filename, apr_int32_t flags, S32* sizep = NULL); | 221 | apr_status_t open(const std::string& filename, apr_int32_t flags, access_t access_type, S32* sizep = NULL); |
206 | apr_status_t open(const std::string& filename, apr_int32_t flags, apr_pool_t* pool = NULL, S32* sizep = NULL); | ||
207 | apr_status_t close() ; | 222 | apr_status_t close() ; |
208 | 223 | ||
209 | // Returns actual offset, -1 if seek fails | 224 | // Returns actual offset, -1 if seek fails |
@@ -216,32 +231,24 @@ public: | |||
216 | 231 | ||
217 | apr_file_t* getFileHandle() {return mFile;} | 232 | apr_file_t* getFileHandle() {return mFile;} |
218 | 233 | ||
219 | private: | ||
220 | apr_pool_t* getAPRFilePool(apr_pool_t* pool) ; | ||
221 | |||
222 | // | 234 | // |
223 | //******************************************************************************************************************************* | 235 | //******************************************************************************************************************************* |
224 | //static components | 236 | //static components |
225 | // | 237 | // |
226 | public: | ||
227 | static LLVolatileAPRPool *sAPRFilePoolp ; //a global apr_pool for APRFile, which is used only when local pool does not exist. | ||
228 | |||
229 | private: | 238 | private: |
230 | static apr_file_t* open(const std::string& filename, LLVolatileAPRPool* pool, apr_int32_t flags); | ||
231 | static apr_status_t close(apr_file_t* file, LLVolatileAPRPool* pool) ; | ||
232 | static S32 seek(apr_file_t* file, apr_seek_where_t where, S32 offset); | 239 | static S32 seek(apr_file_t* file, apr_seek_where_t where, S32 offset); |
233 | public: | 240 | public: |
234 | // returns false if failure: | 241 | // returns false if failure: |
235 | static bool remove(const std::string& filename, LLVolatileAPRPool* pool = NULL); | 242 | static bool remove(const std::string& filename); |
236 | static bool rename(const std::string& filename, const std::string& newname, LLVolatileAPRPool* pool = NULL); | 243 | static bool rename(const std::string& filename, const std::string& newname); |
237 | static bool isExist(const std::string& filename, LLVolatileAPRPool* pool = NULL, apr_int32_t flags = APR_READ); | 244 | static bool isExist(const std::string& filename, apr_int32_t flags = APR_READ); |
238 | static S32 size(const std::string& filename, LLVolatileAPRPool* pool = NULL); | 245 | static S32 size(const std::string& filename); |
239 | static bool makeDir(const std::string& dirname, LLVolatileAPRPool* pool = NULL); | 246 | static bool makeDir(const std::string& dirname); |
240 | static bool removeDir(const std::string& dirname, LLVolatileAPRPool* pool = NULL); | 247 | static bool removeDir(const std::string& dirname); |
241 | 248 | ||
242 | // Returns bytes read/written, 0 if read/write fails: | 249 | // Returns bytes read/written, 0 if read/write fails: |
243 | static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); | 250 | static S32 readEx(const std::string& filename, void *buf, S32 offset, S32 nbytes); |
244 | static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes, LLVolatileAPRPool* pool = NULL); | 251 | static S32 writeEx(const std::string& filename, void *buf, S32 offset, S32 nbytes); |
245 | //******************************************************************************************************************************* | 252 | //******************************************************************************************************************************* |
246 | }; | 253 | }; |
247 | 254 | ||
diff --git a/linden/indra/llcommon/llthread.cpp b/linden/indra/llcommon/llthread.cpp index 37b03a4..b39ffb6 100644 --- a/linden/indra/llcommon/llthread.cpp +++ b/linden/indra/llcommon/llthread.cpp | |||
@@ -72,6 +72,9 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap | |||
72 | // Set thread state to running | 72 | // Set thread state to running |
73 | threadp->mStatus = RUNNING; | 73 | threadp->mStatus = RUNNING; |
74 | 74 | ||
75 | // Create a thread local APRFile pool. | ||
76 | LLVolatileAPRPool::createLocalAPRFilePool(); | ||
77 | |||
75 | // Run the user supplied function | 78 | // Run the user supplied function |
76 | threadp->run(); | 79 | threadp->run(); |
77 | 80 | ||
@@ -102,20 +105,12 @@ LLThread::LLThread(const std::string& name, apr_pool_t *poolp) : | |||
102 | apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread | 105 | apr_pool_create(&mAPRPoolp, NULL); // Create a subpool for this thread |
103 | } | 106 | } |
104 | mRunCondition = new LLCondition(mAPRPoolp); | 107 | mRunCondition = new LLCondition(mAPRPoolp); |
105 | |||
106 | mLocalAPRFilePoolp = NULL ; | ||
107 | } | 108 | } |
108 | 109 | ||
109 | 110 | ||
110 | LLThread::~LLThread() | 111 | LLThread::~LLThread() |
111 | { | 112 | { |
112 | shutdown(); | 113 | shutdown(); |
113 | |||
114 | if(mLocalAPRFilePoolp) | ||
115 | { | ||
116 | delete mLocalAPRFilePoolp ; | ||
117 | mLocalAPRFilePoolp = NULL ; | ||
118 | } | ||
119 | } | 114 | } |
120 | 115 | ||
121 | void LLThread::shutdown() | 116 | void LLThread::shutdown() |
diff --git a/linden/indra/llcommon/llthread.h b/linden/indra/llcommon/llthread.h index 457f45b..721b6e7 100644 --- a/linden/indra/llcommon/llthread.h +++ b/linden/indra/llcommon/llthread.h | |||
@@ -83,7 +83,6 @@ public: | |||
83 | void start(void); | 83 | void start(void); |
84 | 84 | ||
85 | apr_pool_t *getAPRPool() { return mAPRPoolp; } | 85 | apr_pool_t *getAPRPool() { return mAPRPoolp; } |
86 | LLVolatileAPRPool* getLocalAPRFilePool() { return mLocalAPRFilePoolp ; } | ||
87 | 86 | ||
88 | private: | 87 | private: |
89 | bool mPaused; | 88 | bool mPaused; |
@@ -100,11 +99,6 @@ protected: | |||
100 | bool mIsLocalPool; | 99 | bool mIsLocalPool; |
101 | EThreadStatus mStatus; | 100 | EThreadStatus mStatus; |
102 | 101 | ||
103 | //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. | ||
104 | //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. | ||
105 | // otherwise it will cause severe memory leaking!!! --bao | ||
106 | LLVolatileAPRPool *mLocalAPRFilePoolp ; | ||
107 | |||
108 | void setQuitting(); | 102 | void setQuitting(); |
109 | 103 | ||
110 | // virtual function overridden by subclass -- this will be called when the thread runs | 104 | // virtual function overridden by subclass -- this will be called when the thread runs |
diff --git a/linden/indra/llcommon/llworkerthread.cpp b/linden/indra/llcommon/llworkerthread.cpp index 5dda600..68d32db 100644 --- a/linden/indra/llcommon/llworkerthread.cpp +++ b/linden/indra/llcommon/llworkerthread.cpp | |||
@@ -44,11 +44,6 @@ LLWorkerThread::LLWorkerThread(const std::string& name, bool threaded) : | |||
44 | LLQueuedThread(name, threaded) | 44 | LLQueuedThread(name, threaded) |
45 | { | 45 | { |
46 | mDeleteMutex = new LLMutex(NULL); | 46 | mDeleteMutex = new LLMutex(NULL); |
47 | |||
48 | if(!mLocalAPRFilePoolp) | ||
49 | { | ||
50 | mLocalAPRFilePoolp = new LLVolatileAPRPool() ; | ||
51 | } | ||
52 | } | 47 | } |
53 | 48 | ||
54 | LLWorkerThread::~LLWorkerThread() | 49 | LLWorkerThread::~LLWorkerThread() |
diff --git a/linden/indra/llimage/llimage.cpp b/linden/indra/llimage/llimage.cpp index 88edc99..4b0076e 100644 --- a/linden/indra/llimage/llimage.cpp +++ b/linden/indra/llimage/llimage.cpp | |||
@@ -1514,7 +1514,7 @@ BOOL LLImageFormatted::load(const std::string &filename) | |||
1514 | 1514 | ||
1515 | S32 file_size = 0; | 1515 | S32 file_size = 0; |
1516 | LLAPRFile infile ; | 1516 | LLAPRFile infile ; |
1517 | infile.open(filename, LL_APR_RB, NULL, &file_size); | 1517 | infile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size); |
1518 | apr_file_t* apr_file = infile.getFileHandle(); | 1518 | apr_file_t* apr_file = infile.getFileHandle(); |
1519 | if (!apr_file) | 1519 | if (!apr_file) |
1520 | { | 1520 | { |
@@ -1550,7 +1550,7 @@ BOOL LLImageFormatted::save(const std::string &filename) | |||
1550 | resetLastError(); | 1550 | resetLastError(); |
1551 | 1551 | ||
1552 | LLAPRFile outfile ; | 1552 | LLAPRFile outfile ; |
1553 | outfile.open(filename, LL_APR_WB); | 1553 | outfile.open(filename, LL_APR_WB, LLAPRFile::global); |
1554 | if (!outfile.getFileHandle()) | 1554 | if (!outfile.getFileHandle()) |
1555 | { | 1555 | { |
1556 | setLastError("Unable to open file for writing", filename); | 1556 | setLastError("Unable to open file for writing", filename); |
diff --git a/linden/indra/llimage/llimagej2c.cpp b/linden/indra/llimage/llimagej2c.cpp index 1b93c21..ed58f85 100644 --- a/linden/indra/llimage/llimagej2c.cpp +++ b/linden/indra/llimage/llimagej2c.cpp | |||
@@ -420,7 +420,7 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename) | |||
420 | 420 | ||
421 | S32 file_size = 0; | 421 | S32 file_size = 0; |
422 | LLAPRFile infile ; | 422 | LLAPRFile infile ; |
423 | infile.open(filename, LL_APR_RB, NULL, &file_size); | 423 | infile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size); |
424 | apr_file_t* apr_file = infile.getFileHandle() ; | 424 | apr_file_t* apr_file = infile.getFileHandle() ; |
425 | if (!apr_file) | 425 | if (!apr_file) |
426 | { | 426 | { |
diff --git a/linden/indra/llmessage/llcurl.cpp b/linden/indra/llmessage/llcurl.cpp index a4eb90d..811d4af 100644 --- a/linden/indra/llmessage/llcurl.cpp +++ b/linden/indra/llmessage/llcurl.cpp | |||
@@ -1002,7 +1002,7 @@ void LLCurl::initClass() | |||
1002 | S32 mutex_count = CRYPTO_num_locks(); | 1002 | S32 mutex_count = CRYPTO_num_locks(); |
1003 | for (S32 i=0; i<mutex_count; i++) | 1003 | for (S32 i=0; i<mutex_count; i++) |
1004 | { | 1004 | { |
1005 | sSSLMutex.push_back(new LLMutex(gAPRPoolp)); | 1005 | sSSLMutex.push_back(new LLMutex(NULL)); |
1006 | } | 1006 | } |
1007 | CRYPTO_set_id_callback(&LLCurl::ssl_thread_id); | 1007 | CRYPTO_set_id_callback(&LLCurl::ssl_thread_id); |
1008 | CRYPTO_set_locking_callback(&LLCurl::ssl_locking_callback); | 1008 | CRYPTO_set_locking_callback(&LLCurl::ssl_locking_callback); |
diff --git a/linden/indra/llvfs/lllfsthread.cpp b/linden/indra/llvfs/lllfsthread.cpp index 704e1ab..cd91220 100644 --- a/linden/indra/llvfs/lllfsthread.cpp +++ b/linden/indra/llvfs/lllfsthread.cpp | |||
@@ -73,10 +73,6 @@ LLLFSThread::LLLFSThread(bool threaded) : | |||
73 | LLQueuedThread("LFS", threaded), | 73 | LLQueuedThread("LFS", threaded), |
74 | mPriorityCounter(PRIORITY_LOWBITS) | 74 | mPriorityCounter(PRIORITY_LOWBITS) |
75 | { | 75 | { |
76 | if(!mLocalAPRFilePoolp) | ||
77 | { | ||
78 | mLocalAPRFilePoolp = new LLVolatileAPRPool() ; | ||
79 | } | ||
80 | } | 76 | } |
81 | 77 | ||
82 | LLLFSThread::~LLLFSThread() | 78 | LLLFSThread::~LLLFSThread() |
@@ -189,7 +185,7 @@ bool LLLFSThread::Request::processRequest() | |||
189 | { | 185 | { |
190 | llassert(mOffset >= 0); | 186 | llassert(mOffset >= 0); |
191 | LLAPRFile infile ; | 187 | LLAPRFile infile ; |
192 | infile.open(mThread->getLocalAPRFilePool(), mFileName, LL_APR_RB); | 188 | infile.open(mFileName, LL_APR_RB, LLAPRFile::local); |
193 | if (!infile.getFileHandle()) | 189 | if (!infile.getFileHandle()) |
194 | { | 190 | { |
195 | llwarns << "LLLFS: Unable to read file: " << mFileName << llendl; | 191 | llwarns << "LLLFS: Unable to read file: " << mFileName << llendl; |
@@ -213,7 +209,7 @@ bool LLLFSThread::Request::processRequest() | |||
213 | if (mOffset < 0) | 209 | if (mOffset < 0) |
214 | flags |= APR_APPEND; | 210 | flags |= APR_APPEND; |
215 | LLAPRFile outfile ; | 211 | LLAPRFile outfile ; |
216 | outfile.open(mThread->getLocalAPRFilePool(), mFileName, flags); | 212 | outfile.open(mFileName, flags, LLAPRFile::local); |
217 | if (!outfile.getFileHandle()) | 213 | if (!outfile.getFileHandle()) |
218 | { | 214 | { |
219 | llwarns << "LLLFS: Unable to write file: " << mFileName << llendl; | 215 | llwarns << "LLLFS: Unable to write file: " << mFileName << llendl; |
diff --git a/linden/indra/llvfs/llvfs.cpp b/linden/indra/llvfs/llvfs.cpp index e5ffce4..7df2a81 100644 --- a/linden/indra/llvfs/llvfs.cpp +++ b/linden/indra/llvfs/llvfs.cpp | |||
@@ -2089,7 +2089,7 @@ void LLVFS::dumpFiles() | |||
2089 | llinfos << " Writing " << filename << llendl; | 2089 | llinfos << " Writing " << filename << llendl; |
2090 | 2090 | ||
2091 | LLAPRFile outfile ; | 2091 | LLAPRFile outfile ; |
2092 | outfile.open(filename, LL_APR_WB); | 2092 | outfile.open(filename, LL_APR_WB, LLAPRFile::global); |
2093 | outfile.write(buffer, size); | 2093 | outfile.write(buffer, size); |
2094 | outfile.close(); | 2094 | outfile.close(); |
2095 | delete[] buffer; | 2095 | delete[] buffer; |
diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index a57050d..cdecaf4 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp | |||
@@ -2487,7 +2487,7 @@ void LLAppViewer::handleViewerCrash() | |||
2487 | llinfos << "Creating crash marker file " << crash_file_name << llendl; | 2487 | llinfos << "Creating crash marker file " << crash_file_name << llendl; |
2488 | 2488 | ||
2489 | LLAPRFile crash_file ; | 2489 | LLAPRFile crash_file ; |
2490 | crash_file.open(crash_file_name, LL_APR_W); | 2490 | crash_file.open(crash_file_name, LL_APR_W, LLAPRFile::local); |
2491 | if (crash_file.getFileHandle()) | 2491 | if (crash_file.getFileHandle()) |
2492 | { | 2492 | { |
2493 | LL_INFOS("MarkerFile") << "Created crash marker file " << crash_file_name << LL_ENDL; | 2493 | LL_INFOS("MarkerFile") << "Created crash marker file " << crash_file_name << LL_ENDL; |
@@ -2555,11 +2555,11 @@ bool LLAppViewer::anotherInstanceRunning() | |||
2555 | LL_DEBUGS("MarkerFile") << "Checking marker file for lock..." << LL_ENDL; | 2555 | LL_DEBUGS("MarkerFile") << "Checking marker file for lock..." << LL_ENDL; |
2556 | 2556 | ||
2557 | //Freeze case checks | 2557 | //Freeze case checks |
2558 | if (LLAPRFile::isExist(marker_file, NULL, LL_APR_RB)) | 2558 | if (LLAPRFile::isExist(marker_file, LL_APR_RB)) |
2559 | { | 2559 | { |
2560 | // File exists, try opening with write permissions | 2560 | // File exists, try opening with write permissions |
2561 | LLAPRFile outfile ; | 2561 | LLAPRFile outfile ; |
2562 | outfile.open(marker_file, LL_APR_WB); | 2562 | outfile.open(marker_file, LL_APR_WB, LLAPRFile::global); |
2563 | apr_file_t* fMarker = outfile.getFileHandle() ; | 2563 | apr_file_t* fMarker = outfile.getFileHandle() ; |
2564 | if (!fMarker) | 2564 | if (!fMarker) |
2565 | { | 2565 | { |
@@ -2599,24 +2599,24 @@ void LLAppViewer::initMarkerFile() | |||
2599 | std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); | 2599 | std::string error_marker_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, ERROR_MARKER_FILE_NAME); |
2600 | 2600 | ||
2601 | 2601 | ||
2602 | if (LLAPRFile::isExist(mMarkerFileName, NULL, LL_APR_RB) && !anotherInstanceRunning()) | 2602 | if (LLAPRFile::isExist(mMarkerFileName, LL_APR_RB) && !anotherInstanceRunning()) |
2603 | { | 2603 | { |
2604 | gLastExecEvent = LAST_EXEC_FROZE; | 2604 | gLastExecEvent = LAST_EXEC_FROZE; |
2605 | LL_INFOS("MarkerFile") << "Exec marker found: program froze on previous execution" << LL_ENDL; | 2605 | LL_INFOS("MarkerFile") << "Exec marker found: program froze on previous execution" << LL_ENDL; |
2606 | } | 2606 | } |
2607 | 2607 | ||
2608 | if(LLAPRFile::isExist(logout_marker_file, NULL, LL_APR_RB)) | 2608 | if(LLAPRFile::isExist(logout_marker_file, LL_APR_RB)) |
2609 | { | 2609 | { |
2610 | LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << LL_ENDL; | 2610 | LL_INFOS("MarkerFile") << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << LL_ENDL; |
2611 | gLastExecEvent = LAST_EXEC_LOGOUT_FROZE; | 2611 | gLastExecEvent = LAST_EXEC_LOGOUT_FROZE; |
2612 | } | 2612 | } |
2613 | if(LLAPRFile::isExist(llerror_marker_file, NULL, LL_APR_RB)) | 2613 | if(LLAPRFile::isExist(llerror_marker_file, LL_APR_RB)) |
2614 | { | 2614 | { |
2615 | llinfos << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << llendl; | 2615 | llinfos << "Last exec LLError crashed, setting LastExecEvent to " << LAST_EXEC_LLERROR_CRASH << llendl; |
2616 | if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; | 2616 | if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; |
2617 | else gLastExecEvent = LAST_EXEC_LLERROR_CRASH; | 2617 | else gLastExecEvent = LAST_EXEC_LLERROR_CRASH; |
2618 | } | 2618 | } |
2619 | if(LLAPRFile::isExist(error_marker_file, NULL, LL_APR_RB)) | 2619 | if(LLAPRFile::isExist(error_marker_file, LL_APR_RB)) |
2620 | { | 2620 | { |
2621 | LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << LL_ENDL; | 2621 | LL_INFOS("MarkerFile") << "Last exec crashed, setting LastExecEvent to " << LAST_EXEC_OTHER_CRASH << LL_ENDL; |
2622 | if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; | 2622 | if(gLastExecEvent == LAST_EXEC_LOGOUT_FROZE) gLastExecEvent = LAST_EXEC_LOGOUT_CRASH; |
@@ -2635,7 +2635,7 @@ void LLAppViewer::initMarkerFile() | |||
2635 | 2635 | ||
2636 | // Create the marker file for this execution & lock it | 2636 | // Create the marker file for this execution & lock it |
2637 | apr_status_t s; | 2637 | apr_status_t s; |
2638 | s = mMarkerFile.open(mMarkerFileName, LL_APR_W, gAPRPoolp); | 2638 | s = mMarkerFile.open(mMarkerFileName, LL_APR_W, LLAPRFile::global); |
2639 | 2639 | ||
2640 | if (s == APR_SUCCESS && mMarkerFile.getFileHandle()) | 2640 | if (s == APR_SUCCESS && mMarkerFile.getFileHandle()) |
2641 | { | 2641 | { |
@@ -3716,7 +3716,7 @@ void LLAppViewer::sendLogoutRequest() | |||
3716 | mLogoutMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LOGOUT_MARKER_FILE_NAME); | 3716 | mLogoutMarkerFileName = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,LOGOUT_MARKER_FILE_NAME); |
3717 | 3717 | ||
3718 | LLAPRFile outfile ; | 3718 | LLAPRFile outfile ; |
3719 | outfile.open(mLogoutMarkerFileName, LL_APR_W); | 3719 | outfile.open(mLogoutMarkerFileName, LL_APR_W, LLAPRFile::global); |
3720 | mLogoutMarkerFile = outfile.getFileHandle() ; | 3720 | mLogoutMarkerFile = outfile.getFileHandle() ; |
3721 | if (mLogoutMarkerFile) | 3721 | if (mLogoutMarkerFile) |
3722 | { | 3722 | { |
diff --git a/linden/indra/newview/llfloateranimpreview.cpp b/linden/indra/newview/llfloateranimpreview.cpp index 162456b..57ee161 100644 --- a/linden/indra/newview/llfloateranimpreview.cpp +++ b/linden/indra/newview/llfloateranimpreview.cpp | |||
@@ -238,7 +238,7 @@ BOOL LLFloaterAnimPreview::postBuild() | |||
238 | S32 file_size; | 238 | S32 file_size; |
239 | 239 | ||
240 | LLAPRFile infile ; | 240 | LLAPRFile infile ; |
241 | infile.open(mFilenameAndPath, LL_APR_RB, NULL, &file_size); | 241 | infile.open(mFilenameAndPath, LL_APR_RB, LLAPRFile::global, &file_size); |
242 | 242 | ||
243 | if (!infile.getFileHandle()) | 243 | if (!infile.getFileHandle()) |
244 | { | 244 | { |
diff --git a/linden/indra/newview/lltexturecache.cpp b/linden/indra/newview/lltexturecache.cpp index 3b724e2..9c3bed2 100644 --- a/linden/indra/newview/lltexturecache.cpp +++ b/linden/indra/newview/lltexturecache.cpp | |||
@@ -175,7 +175,7 @@ private: | |||
175 | 175 | ||
176 | bool LLTextureCacheLocalFileWorker::doRead() | 176 | bool LLTextureCacheLocalFileWorker::doRead() |
177 | { | 177 | { |
178 | S32 local_size = LLAPRFile::size(mFileName, mCache->getLocalAPRFilePool()); | 178 | S32 local_size = LLAPRFile::size(mFileName); |
179 | 179 | ||
180 | if (local_size > 0 && mFileName.size() > 4) | 180 | if (local_size > 0 && mFileName.size() > 4) |
181 | { | 181 | { |
@@ -249,7 +249,7 @@ bool LLTextureCacheLocalFileWorker::doRead() | |||
249 | } | 249 | } |
250 | mReadData = new U8[mDataSize]; | 250 | mReadData = new U8[mDataSize]; |
251 | 251 | ||
252 | S32 bytes_read = LLAPRFile::readEx(mFileName, mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool()); | 252 | S32 bytes_read = LLAPRFile::readEx(mFileName, mReadData, mOffset, mDataSize); |
253 | 253 | ||
254 | if (bytes_read != mDataSize) | 254 | if (bytes_read != mDataSize) |
255 | { | 255 | { |
@@ -318,11 +318,11 @@ bool LLTextureCacheRemoteWorker::doRead() | |||
318 | { | 318 | { |
319 | std::string filename = mCache->getLocalFileName(mID); | 319 | std::string filename = mCache->getLocalFileName(mID); |
320 | local_filename = filename + ".j2c"; | 320 | local_filename = filename + ".j2c"; |
321 | local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool()); | 321 | local_size = LLAPRFile::size(local_filename); |
322 | if (local_size == 0) | 322 | if (local_size == 0) |
323 | { | 323 | { |
324 | local_filename = filename + ".tga"; | 324 | local_filename = filename + ".tga"; |
325 | local_size = LLAPRFile::size(local_filename, mCache->getLocalAPRFilePool()); | 325 | local_size = LLAPRFile::size(local_filename); |
326 | if (local_size > 0) | 326 | if (local_size > 0) |
327 | { | 327 | { |
328 | mImageFormat = IMG_CODEC_TGA; | 328 | mImageFormat = IMG_CODEC_TGA; |
@@ -390,8 +390,7 @@ bool LLTextureCacheRemoteWorker::doRead() | |||
390 | mDataSize = local_size; | 390 | mDataSize = local_size; |
391 | } | 391 | } |
392 | mReadData = new U8[mDataSize]; | 392 | mReadData = new U8[mDataSize]; |
393 | S32 bytes_read = LLAPRFile::readEx(local_filename, | 393 | S32 bytes_read = LLAPRFile::readEx(local_filename, mReadData, mOffset, mDataSize); |
394 | mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool()); | ||
395 | if (bytes_read != mDataSize) | 394 | if (bytes_read != mDataSize) |
396 | { | 395 | { |
397 | // llwarns << "Error reading file from local cache: " << local_filename | 396 | // llwarns << "Error reading file from local cache: " << local_filename |
@@ -485,7 +484,7 @@ bool LLTextureCacheRemoteWorker::doRead() | |||
485 | S32 size = TEXTURE_CACHE_ENTRY_SIZE - mOffset; | 484 | S32 size = TEXTURE_CACHE_ENTRY_SIZE - mOffset; |
486 | mReadData = new U8[size]; | 485 | mReadData = new U8[size]; |
487 | S32 bytes_read = LLAPRFile::readEx(mCache->mHeaderDataFileName, | 486 | S32 bytes_read = LLAPRFile::readEx(mCache->mHeaderDataFileName, |
488 | mReadData, offset, size, mCache->getLocalAPRFilePool()); | 487 | mReadData, offset, size); |
489 | if (bytes_read != size) | 488 | if (bytes_read != size) |
490 | { | 489 | { |
491 | // llwarns << "LLTextureCacheWorker: " << mID | 490 | // llwarns << "LLTextureCacheWorker: " << mID |
@@ -511,7 +510,7 @@ bool LLTextureCacheRemoteWorker::doRead() | |||
511 | if (mFileHandle == LLLFSThread::nullHandle()) | 510 | if (mFileHandle == LLLFSThread::nullHandle()) |
512 | { | 511 | { |
513 | std::string filename = mCache->getTextureFileName(mID); | 512 | std::string filename = mCache->getTextureFileName(mID); |
514 | S32 filesize = LLAPRFile::size(filename, mCache->getLocalAPRFilePool()); | 513 | S32 filesize = LLAPRFile::size(filename); |
515 | if (filesize > mOffset) | 514 | if (filesize > mOffset) |
516 | { | 515 | { |
517 | S32 datasize = TEXTURE_CACHE_ENTRY_SIZE + filesize; | 516 | S32 datasize = TEXTURE_CACHE_ENTRY_SIZE + filesize; |
@@ -570,7 +569,7 @@ bool LLTextureCacheRemoteWorker::doRead() | |||
570 | } | 569 | } |
571 | #else | 570 | #else |
572 | std::string filename = mCache->getTextureFileName(mID); | 571 | std::string filename = mCache->getTextureFileName(mID); |
573 | S32 filesize = LLAPRFile::size(filename, mCache->getLocalAPRFilePool()); | 572 | S32 filesize = LLAPRFile::size(filename); |
574 | S32 bytes_read = 0; | 573 | S32 bytes_read = 0; |
575 | if (filesize > mOffset) | 574 | if (filesize > mOffset) |
576 | { | 575 | { |
@@ -592,8 +591,7 @@ bool LLTextureCacheRemoteWorker::doRead() | |||
592 | mReadData = data; | 591 | mReadData = data; |
593 | bytes_read = LLAPRFile::readEx(filename, | 592 | bytes_read = LLAPRFile::readEx(filename, |
594 | mReadData + data_offset, | 593 | mReadData + data_offset, |
595 | file_offset, file_size, | 594 | file_offset, file_size); |
596 | mCache->getLocalAPRFilePool()); | ||
597 | if (bytes_read != file_size) | 595 | if (bytes_read != file_size) |
598 | { | 596 | { |
599 | // llwarns << "LLTextureCacheWorker: " << mID | 597 | // llwarns << "LLTextureCacheWorker: " << mID |
@@ -696,7 +694,7 @@ bool LLTextureCacheRemoteWorker::doWrite() | |||
696 | llassert_always(mOffset < TEXTURE_CACHE_ENTRY_SIZE); | 694 | llassert_always(mOffset < TEXTURE_CACHE_ENTRY_SIZE); |
697 | S32 offset = idx * TEXTURE_CACHE_ENTRY_SIZE + mOffset; | 695 | S32 offset = idx * TEXTURE_CACHE_ENTRY_SIZE + mOffset; |
698 | S32 size = TEXTURE_CACHE_ENTRY_SIZE - mOffset; | 696 | S32 size = TEXTURE_CACHE_ENTRY_SIZE - mOffset; |
699 | S32 bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, mWriteData, offset, size, mCache->getLocalAPRFilePool()); | 697 | S32 bytes_written = LLAPRFile::writeEx(mCache->mHeaderDataFileName, mWriteData, offset, size); |
700 | 698 | ||
701 | if (bytes_written <= 0) | 699 | if (bytes_written <= 0) |
702 | { | 700 | { |
@@ -774,8 +772,7 @@ bool LLTextureCacheRemoteWorker::doWrite() | |||
774 | 772 | ||
775 | bytes_written = LLAPRFile::writeEx(filename, | 773 | bytes_written = LLAPRFile::writeEx(filename, |
776 | mWriteData + data_offset, | 774 | mWriteData + data_offset, |
777 | file_offset, file_size, | 775 | file_offset, file_size); |
778 | mCache->getLocalAPRFilePool()); | ||
779 | if (bytes_written <= 0) | 776 | if (bytes_written <= 0) |
780 | { | 777 | { |
781 | mDataSize = -1; // failed | 778 | mDataSize = -1; // failed |
@@ -975,8 +972,7 @@ bool LLTextureCache::appendToTextureEntryList(const LLUUID& id, S32 bodysize) | |||
975 | Entry* entry = new Entry(id, bodysize, time(NULL)); | 972 | Entry* entry = new Entry(id, bodysize, time(NULL)); |
976 | 973 | ||
977 | LLAPRFile::writeEx(mTexturesDirEntriesFileName, | 974 | LLAPRFile::writeEx(mTexturesDirEntriesFileName, |
978 | (U8*)entry, -1, 1*sizeof(Entry), | 975 | (U8*)entry, -1, 1*sizeof(Entry)); |
979 | getLocalAPRFilePool()); | ||
980 | delete entry; | 976 | delete entry; |
981 | if (iter != mTexturesSizeMap.end()) | 977 | if (iter != mTexturesSizeMap.end()) |
982 | { | 978 | { |
@@ -1024,8 +1020,8 @@ void LLTextureCache::purgeCache(ELLPath location) | |||
1024 | { | 1020 | { |
1025 | setDirNames(location); | 1021 | setDirNames(location); |
1026 | 1022 | ||
1027 | LLAPRFile::remove(mHeaderEntriesFileName, getLocalAPRFilePool()); | 1023 | LLAPRFile::remove(mHeaderEntriesFileName); |
1028 | LLAPRFile::remove(mHeaderDataFileName, getLocalAPRFilePool()); | 1024 | LLAPRFile::remove(mHeaderDataFileName); |
1029 | } | 1025 | } |
1030 | purgeAllTextures(true); | 1026 | purgeAllTextures(true); |
1031 | } | 1027 | } |
@@ -1092,11 +1088,10 @@ void LLTextureCache::readHeaderCache() | |||
1092 | LLMutexLock lock(&mHeaderMutex); | 1088 | LLMutexLock lock(&mHeaderMutex); |
1093 | mHeaderEntriesInfo.mVersion = 0.f; | 1089 | mHeaderEntriesInfo.mVersion = 0.f; |
1094 | mHeaderEntriesInfo.mEntries = 0; | 1090 | mHeaderEntriesInfo.mEntries = 0; |
1095 | if (LLAPRFile::isExist(mHeaderEntriesFileName, getLocalAPRFilePool())) | 1091 | if (LLAPRFile::isExist(mHeaderEntriesFileName)) |
1096 | { | 1092 | { |
1097 | LLAPRFile::readEx(mHeaderEntriesFileName, | 1093 | LLAPRFile::readEx(mHeaderEntriesFileName, |
1098 | (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), | 1094 | (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo)); |
1099 | getLocalAPRFilePool()); | ||
1100 | } | 1095 | } |
1101 | if (mHeaderEntriesInfo.mVersion != sHeaderCacheVersion) | 1096 | if (mHeaderEntriesInfo.mVersion != sHeaderCacheVersion) |
1102 | { | 1097 | { |
@@ -1106,8 +1101,7 @@ void LLTextureCache::readHeaderCache() | |||
1106 | mHeaderEntriesInfo.mVersion = sHeaderCacheVersion; | 1101 | mHeaderEntriesInfo.mVersion = sHeaderCacheVersion; |
1107 | 1102 | ||
1108 | LLAPRFile::writeEx(mHeaderEntriesFileName, | 1103 | LLAPRFile::writeEx(mHeaderEntriesFileName, |
1109 | (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), | 1104 | (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo)); |
1110 | getLocalAPRFilePool()); | ||
1111 | } | 1105 | } |
1112 | } | 1106 | } |
1113 | else | 1107 | else |
@@ -1118,8 +1112,7 @@ void LLTextureCache::readHeaderCache() | |||
1118 | Entry* entries = new Entry[num_entries]; | 1112 | Entry* entries = new Entry[num_entries]; |
1119 | { | 1113 | { |
1120 | LLAPRFile::readEx(mHeaderEntriesFileName, | 1114 | LLAPRFile::readEx(mHeaderEntriesFileName, |
1121 | (U8*)entries, sizeof(EntriesInfo), num_entries*sizeof(Entry), | 1115 | (U8*)entries, sizeof(EntriesInfo), num_entries*sizeof(Entry)); |
1122 | getLocalAPRFilePool()); | ||
1123 | } | 1116 | } |
1124 | typedef std::set<lru_data*, lru_data::Compare> lru_set_t; | 1117 | typedef std::set<lru_data*, lru_data::Compare> lru_set_t; |
1125 | lru_set_t lru; | 1118 | lru_set_t lru; |
@@ -1165,7 +1158,7 @@ void LLTextureCache::purgeAllTextures(bool purge_directories) | |||
1165 | LLFile::rmdir(dirname); | 1158 | LLFile::rmdir(dirname); |
1166 | } | 1159 | } |
1167 | } | 1160 | } |
1168 | LLAPRFile::remove(mTexturesDirEntriesFileName, getLocalAPRFilePool()); | 1161 | LLAPRFile::remove(mTexturesDirEntriesFileName); |
1169 | if (purge_directories) | 1162 | if (purge_directories) |
1170 | { | 1163 | { |
1171 | LLFile::rmdir(mTexturesDirName); | 1164 | LLFile::rmdir(mTexturesDirName); |
@@ -1186,7 +1179,7 @@ void LLTextureCache::purgeTextures(bool validate) | |||
1186 | 1179 | ||
1187 | LLMutexLock lock(&mHeaderMutex); | 1180 | LLMutexLock lock(&mHeaderMutex); |
1188 | 1181 | ||
1189 | S32 filesize = LLAPRFile::size(mTexturesDirEntriesFileName, getLocalAPRFilePool()); | 1182 | S32 filesize = LLAPRFile::size(mTexturesDirEntriesFileName); |
1190 | S32 num_entries = filesize / sizeof(Entry); | 1183 | S32 num_entries = filesize / sizeof(Entry); |
1191 | if (num_entries * (S32)sizeof(Entry) != filesize) | 1184 | if (num_entries * (S32)sizeof(Entry) != filesize) |
1192 | { | 1185 | { |
@@ -1201,8 +1194,7 @@ void LLTextureCache::purgeTextures(bool validate) | |||
1201 | 1194 | ||
1202 | Entry* entries = new Entry[num_entries]; | 1195 | Entry* entries = new Entry[num_entries]; |
1203 | S32 bytes_read = LLAPRFile::readEx(mTexturesDirEntriesFileName, | 1196 | S32 bytes_read = LLAPRFile::readEx(mTexturesDirEntriesFileName, |
1204 | (U8*)entries, 0, num_entries*sizeof(Entry), | 1197 | (U8*)entries, 0, num_entries*sizeof(Entry)); |
1205 | getLocalAPRFilePool()); | ||
1206 | if (bytes_read != filesize) | 1198 | if (bytes_read != filesize) |
1207 | { | 1199 | { |
1208 | LL_WARNS("TextureCache") << "Bad cache file (2): " << mTexturesDirEntriesFileName << " Purging." << LL_ENDL; | 1200 | LL_WARNS("TextureCache") << "Bad cache file (2): " << mTexturesDirEntriesFileName << " Purging." << LL_ENDL; |
@@ -1261,7 +1253,7 @@ void LLTextureCache::purgeTextures(bool validate) | |||
1261 | if (uuididx == validate_idx) | 1253 | if (uuididx == validate_idx) |
1262 | { | 1254 | { |
1263 | LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mSize << LL_ENDL; | 1255 | LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mSize << LL_ENDL; |
1264 | S32 bodysize = LLAPRFile::size(filename, getLocalAPRFilePool()); | 1256 | S32 bodysize = LLAPRFile::size(filename); |
1265 | if (bodysize != entries[idx].mSize) | 1257 | if (bodysize != entries[idx].mSize) |
1266 | { | 1258 | { |
1267 | LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mSize | 1259 | LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mSize |
@@ -1295,10 +1287,9 @@ void LLTextureCache::purgeTextures(bool validate) | |||
1295 | << num_entries << " (" << num_entries*sizeof(Entry)/1024 << "KB)" | 1287 | << num_entries << " (" << num_entries*sizeof(Entry)/1024 << "KB)" |
1296 | << LL_ENDL; | 1288 | << LL_ENDL; |
1297 | 1289 | ||
1298 | LLAPRFile::remove(mTexturesDirEntriesFileName, getLocalAPRFilePool()); | 1290 | LLAPRFile::remove(mTexturesDirEntriesFileName); |
1299 | LLAPRFile::writeEx(mTexturesDirEntriesFileName, | 1291 | LLAPRFile::writeEx(mTexturesDirEntriesFileName, |
1300 | (U8*)&entries[0], 0, num_entries*sizeof(Entry), | 1292 | (U8*)&entries[0], 0, num_entries*sizeof(Entry)); |
1301 | getLocalAPRFilePool()); | ||
1302 | 1293 | ||
1303 | mTexturesSizeTotal = 0; | 1294 | mTexturesSizeTotal = 0; |
1304 | mTexturesSizeMap.clear(); | 1295 | mTexturesSizeMap.clear(); |
@@ -1345,7 +1336,7 @@ void LLTextureCache::purgeTextureFilesTimeSliced(BOOL force_all) | |||
1345 | for (LLTextureCache::filename_list_t::iterator iter = mFilesToDelete.begin(); iter!=mFilesToDelete.end(); ) | 1336 | for (LLTextureCache::filename_list_t::iterator iter = mFilesToDelete.begin(); iter!=mFilesToDelete.end(); ) |
1346 | { | 1337 | { |
1347 | LLTextureCache::filename_list_t::iterator iter2 = iter++; | 1338 | LLTextureCache::filename_list_t::iterator iter2 = iter++; |
1348 | LLAPRFile::remove(*iter2, NULL); | 1339 | LLAPRFile::remove(*iter2); |
1349 | mFilesToDelete.erase(iter2); | 1340 | mFilesToDelete.erase(iter2); |
1350 | howmany++; | 1341 | howmany++; |
1351 | 1342 | ||
@@ -1416,8 +1407,7 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, bool touch, S32* image | |||
1416 | mHeaderIDMap[id] = idx; | 1407 | mHeaderIDMap[id] = idx; |
1417 | // Update Info | 1408 | // Update Info |
1418 | LLAPRFile::writeEx(mHeaderEntriesFileName, | 1409 | LLAPRFile::writeEx(mHeaderEntriesFileName, |
1419 | (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo), | 1410 | (U8*)&mHeaderEntriesInfo, 0, sizeof(EntriesInfo)); |
1420 | getLocalAPRFilePool()); | ||
1421 | } | 1411 | } |
1422 | else if (!mLRU.empty()) | 1412 | else if (!mLRU.empty()) |
1423 | { | 1413 | { |
@@ -1443,8 +1433,7 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, bool touch, S32* image | |||
1443 | Entry* entry = new Entry(id, *imagesize, time(NULL)); | 1433 | Entry* entry = new Entry(id, *imagesize, time(NULL)); |
1444 | S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry); | 1434 | S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry); |
1445 | LLAPRFile::writeEx(mHeaderEntriesFileName, | 1435 | LLAPRFile::writeEx(mHeaderEntriesFileName, |
1446 | (U8*)entry, offset, sizeof(Entry), | 1436 | (U8*)entry, offset, sizeof(Entry)); |
1447 | getLocalAPRFilePool()); | ||
1448 | delete entry; | 1437 | delete entry; |
1449 | } | 1438 | } |
1450 | else if (imagesize) | 1439 | else if (imagesize) |
@@ -1454,8 +1443,7 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, bool touch, S32* image | |||
1454 | S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry); | 1443 | S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry); |
1455 | 1444 | ||
1456 | LLAPRFile::readEx(mHeaderEntriesFileName, | 1445 | LLAPRFile::readEx(mHeaderEntriesFileName, |
1457 | (U8*)&entry, offset, sizeof(Entry), | 1446 | (U8*)&entry, offset, sizeof(Entry)); |
1458 | getLocalAPRFilePool()); | ||
1459 | *imagesize = entry.mSize; | 1447 | *imagesize = entry.mSize; |
1460 | } | 1448 | } |
1461 | } | 1449 | } |
@@ -1608,8 +1596,7 @@ bool LLTextureCache::removeHeaderCacheEntry(const LLUUID& id) | |||
1608 | S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry); | 1596 | S32 offset = sizeof(EntriesInfo) + idx * sizeof(Entry); |
1609 | 1597 | ||
1610 | LLAPRFile::writeEx(mHeaderEntriesFileName, | 1598 | LLAPRFile::writeEx(mHeaderEntriesFileName, |
1611 | (U8*)entry, offset, sizeof(Entry), | 1599 | (U8*)entry, offset, sizeof(Entry)); |
1612 | getLocalAPRFilePool()); | ||
1613 | delete entry; | 1600 | delete entry; |
1614 | mLRU[idx] = id; | 1601 | mLRU[idx] = id; |
1615 | mHeaderIDMap.erase(id); | 1602 | mHeaderIDMap.erase(id); |
@@ -1626,7 +1613,7 @@ void LLTextureCache::removeFromCache(const LLUUID& id) | |||
1626 | if (!mReadOnly) | 1613 | if (!mReadOnly) |
1627 | { | 1614 | { |
1628 | removeHeaderCacheEntry(id); | 1615 | removeHeaderCacheEntry(id); |
1629 | LLAPRFile::remove(getTextureFileName(id), getLocalAPRFilePool()); | 1616 | LLAPRFile::remove(getTextureFileName(id)); |
1630 | } | 1617 | } |
1631 | } | 1618 | } |
1632 | 1619 | ||
diff --git a/linden/indra/newview/llviewermenufile.cpp b/linden/indra/newview/llviewermenufile.cpp index 178fc97..3283391 100644 --- a/linden/indra/newview/llviewermenufile.cpp +++ b/linden/indra/newview/llviewermenufile.cpp | |||
@@ -798,7 +798,7 @@ void upload_new_resource(const std::string& src_filename, std::string name, | |||
798 | // copy this file into the vfs for upload | 798 | // copy this file into the vfs for upload |
799 | S32 file_size; | 799 | S32 file_size; |
800 | LLAPRFile infile ; | 800 | LLAPRFile infile ; |
801 | infile.open(filename, LL_APR_RB, NULL, &file_size); | 801 | infile.open(filename, LL_APR_RB, LLAPRFile::local, &file_size); |
802 | if (infile.getFileHandle()) | 802 | if (infile.getFileHandle()) |
803 | { | 803 | { |
804 | LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); | 804 | LLVFile file(gVFS, uuid, asset_type, LLVFile::WRITE); |
diff --git a/linden/indra/newview/llvoavatar.cpp b/linden/indra/newview/llvoavatar.cpp index c361f49..ab5d83e 100644 --- a/linden/indra/newview/llvoavatar.cpp +++ b/linden/indra/newview/llvoavatar.cpp | |||
@@ -8545,7 +8545,7 @@ void LLVOAvatar::dumpArchetypeXML( void* ) | |||
8545 | { | 8545 | { |
8546 | LLVOAvatar* avatar = gAgent.getAvatarObject(); | 8546 | LLVOAvatar* avatar = gAgent.getAvatarObject(); |
8547 | LLAPRFile outfile ; | 8547 | LLAPRFile outfile ; |
8548 | outfile.open(gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"new archetype.xml"), LL_APR_WB ); | 8548 | outfile.open(gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,"new archetype.xml"), LL_APR_WB, LLAPRFile::global); |
8549 | apr_file_t* file = outfile.getFileHandle() ; | 8549 | apr_file_t* file = outfile.getFileHandle() ; |
8550 | if( !file ) | 8550 | if( !file ) |
8551 | { | 8551 | { |
diff --git a/linden/indra/newview/primbackup.cpp b/linden/indra/newview/primbackup.cpp index 4e0e56f..4f93ddf 100644 --- a/linden/indra/newview/primbackup.cpp +++ b/linden/indra/newview/primbackup.cpp | |||
@@ -1072,7 +1072,7 @@ void primbackup::upload_next_asset() | |||
1072 | S32 file_size; | 1072 | S32 file_size; |
1073 | apr_file_t* fp; | 1073 | apr_file_t* fp; |
1074 | LLAPRFile aFile; | 1074 | LLAPRFile aFile; |
1075 | aFile.open(filename, LL_APR_RB, NULL, &file_size); | 1075 | aFile.open(filename, LL_APR_RB, LLAPRFile::global, &file_size); |
1076 | fp = aFile.getFileHandle(); | 1076 | fp = aFile.getFileHandle(); |
1077 | if (fp) | 1077 | if (fp) |
1078 | { | 1078 | { |