diff options
Diffstat (limited to 'linden/indra/llvfs')
-rw-r--r-- | linden/indra/llvfs/CMakeLists.txt | 2 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir.cpp | 52 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir.h | 16 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_linux.cpp | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_linux.h | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_mac.cpp | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_mac.h | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_solaris.cpp | 56 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_solaris.h | 5 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_win32.cpp | 35 | ||||
-rw-r--r-- | linden/indra/llvfs/lldir_win32.h | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/lllfsthread.cpp | 32 | ||||
-rw-r--r-- | linden/indra/llvfs/lllfsthread.h | 3 | ||||
-rwxr-xr-x | linden/indra/llvfs/llpidlock.cpp | 269 | ||||
-rwxr-xr-x | linden/indra/llvfs/llpidlock.h | 73 | ||||
-rw-r--r-- | linden/indra/llvfs/llvfile.cpp | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/llvfile.h | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/llvfs.cpp | 66 | ||||
-rw-r--r-- | linden/indra/llvfs/llvfs.h | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/llvfsthread.cpp | 3 | ||||
-rw-r--r-- | linden/indra/llvfs/llvfsthread.h | 3 |
21 files changed, 549 insertions, 90 deletions
diff --git a/linden/indra/llvfs/CMakeLists.txt b/linden/indra/llvfs/CMakeLists.txt index c3c12ef..cc0297e 100644 --- a/linden/indra/llvfs/CMakeLists.txt +++ b/linden/indra/llvfs/CMakeLists.txt | |||
@@ -13,6 +13,7 @@ include_directories( | |||
13 | set(llvfs_SOURCE_FILES | 13 | set(llvfs_SOURCE_FILES |
14 | lldir.cpp | 14 | lldir.cpp |
15 | lllfsthread.cpp | 15 | lllfsthread.cpp |
16 | llpidlock.cpp | ||
16 | llvfile.cpp | 17 | llvfile.cpp |
17 | llvfs.cpp | 18 | llvfs.cpp |
18 | llvfsthread.cpp | 19 | llvfsthread.cpp |
@@ -23,6 +24,7 @@ set(llvfs_HEADER_FILES | |||
23 | 24 | ||
24 | lldir.h | 25 | lldir.h |
25 | lllfsthread.h | 26 | lllfsthread.h |
27 | llpidlock.h | ||
26 | llvfile.h | 28 | llvfile.h |
27 | llvfs.h | 29 | llvfs.h |
28 | llvfsthread.h | 30 | llvfsthread.h |
diff --git a/linden/indra/llvfs/lldir.cpp b/linden/indra/llvfs/lldir.cpp index eb705dd..29a3771 100644 --- a/linden/indra/llvfs/lldir.cpp +++ b/linden/indra/llvfs/lldir.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, |
@@ -215,30 +216,44 @@ const std::string LLDir::getCacheDir(bool get_default) const | |||
215 | { | 216 | { |
216 | if (mCacheDir.empty() || get_default) | 217 | if (mCacheDir.empty() || get_default) |
217 | { | 218 | { |
218 | std::string res; | 219 | if (!mDefaultCacheDir.empty()) |
219 | if (getOSCacheDir().empty()) | 220 | { // Set at startup - can't set here due to const API |
221 | return mDefaultCacheDir; | ||
222 | } | ||
223 | |||
224 | std::string res = buildSLOSCacheDir(); | ||
225 | return res; | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | return mCacheDir; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | // Return the default cache directory | ||
234 | std::string LLDir::buildSLOSCacheDir() const | ||
235 | { | ||
236 | std::string res; | ||
237 | if (getOSCacheDir().empty()) | ||
238 | { | ||
239 | if (getOSUserAppDir().empty()) | ||
220 | { | 240 | { |
221 | if (getOSUserAppDir().empty()) | 241 | res = "data"; |
222 | { | ||
223 | res = "data"; | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | res = getOSUserAppDir() + mDirDelimiter + "cache"; | ||
228 | } | ||
229 | } | 242 | } |
230 | else | 243 | else |
231 | { | 244 | { |
232 | res = getOSCacheDir() + mDirDelimiter + "Imprudence"; | 245 | res = getOSUserAppDir() + mDirDelimiter + "cache"; |
233 | } | 246 | } |
234 | return res; | ||
235 | } | 247 | } |
236 | else | 248 | else |
237 | { | 249 | { |
238 | return mCacheDir; | 250 | res = getOSCacheDir() + mDirDelimiter + "Imprudence"; |
239 | } | 251 | } |
252 | return res; | ||
240 | } | 253 | } |
241 | 254 | ||
255 | |||
256 | |||
242 | const std::string &LLDir::getOSCacheDir() const | 257 | const std::string &LLDir::getOSCacheDir() const |
243 | { | 258 | { |
244 | return mOSCacheDir; | 259 | return mOSCacheDir; |
@@ -378,7 +393,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd | |||
378 | case LL_PATH_EXECUTABLE: | 393 | case LL_PATH_EXECUTABLE: |
379 | prefix = getExecutableDir(); | 394 | prefix = getExecutableDir(); |
380 | break; | 395 | break; |
381 | 396 | ||
382 | default: | 397 | default: |
383 | llassert(0); | 398 | llassert(0); |
384 | } | 399 | } |
@@ -418,7 +433,7 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd | |||
418 | expanded_filename.assign(""); | 433 | expanded_filename.assign(""); |
419 | } | 434 | } |
420 | 435 | ||
421 | //llinfos << "*** EXPANDED FILENAME: <" << mExpandedFilename << ">" << llendl; | 436 | //llinfos << "*** EXPANDED FILENAME: <" << expanded_filename << ">" << llendl; |
422 | 437 | ||
423 | return expanded_filename; | 438 | return expanded_filename; |
424 | } | 439 | } |
@@ -654,6 +669,11 @@ void LLDir::dumpCurrentDirectories() | |||
654 | LL_DEBUGS2("AppInit","Directories") << " TempDir: " << getTempDir() << LL_ENDL; | 669 | LL_DEBUGS2("AppInit","Directories") << " TempDir: " << getTempDir() << LL_ENDL; |
655 | LL_DEBUGS2("AppInit","Directories") << " CAFile: " << getCAFile() << LL_ENDL; | 670 | LL_DEBUGS2("AppInit","Directories") << " CAFile: " << getCAFile() << LL_ENDL; |
656 | LL_DEBUGS2("AppInit","Directories") << " SkinDir: " << getSkinDir() << LL_ENDL; | 671 | LL_DEBUGS2("AppInit","Directories") << " SkinDir: " << getSkinDir() << LL_ENDL; |
672 | |||
673 | #if LL_LIBXUL_ENABLED | ||
674 | LL_DEBUGS2("AppInit","Directories") << " HTML Path: " << getExpandedFilename( LL_PATH_HTML, "" ) << llendl; | ||
675 | LL_DEBUGS2("AppInit","Directories") << " Mozilla Profile Path: " << getExpandedFilename( LL_PATH_MOZILLA_PROFILE, "" ) << llendl; | ||
676 | #endif | ||
657 | } | 677 | } |
658 | 678 | ||
659 | 679 | ||
diff --git a/linden/indra/llvfs/lldir.h b/linden/indra/llvfs/lldir.h index 4ab5d85..21dcf5b 100644 --- a/linden/indra/llvfs/lldir.h +++ b/linden/indra/llvfs/lldir.h | |||
@@ -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, |
@@ -32,6 +33,11 @@ | |||
32 | #ifndef LL_LLDIR_H | 33 | #ifndef LL_LLDIR_H |
33 | #define LL_LLDIR_H | 34 | #define LL_LLDIR_H |
34 | 35 | ||
36 | #if LL_SOLARIS | ||
37 | #include <sys/param.h> | ||
38 | #define MAX_PATH MAXPATHLEN | ||
39 | #endif | ||
40 | |||
35 | // these numbers *may* get serialized, so we need to be explicit | 41 | // these numbers *may* get serialized, so we need to be explicit |
36 | typedef enum ELLPath | 42 | typedef enum ELLPath |
37 | { | 43 | { |
@@ -126,6 +132,9 @@ class LLDir | |||
126 | 132 | ||
127 | virtual void dumpCurrentDirectories(); | 133 | virtual void dumpCurrentDirectories(); |
128 | 134 | ||
135 | // Utility routine | ||
136 | std::string buildSLOSCacheDir() const; | ||
137 | |||
129 | protected: | 138 | protected: |
130 | std::string mAppName; // install directory under progams/ ie "SecondLife" | 139 | std::string mAppName; // install directory under progams/ ie "SecondLife" |
131 | std::string mExecutablePathAndName; // full path + Filename of .exe | 140 | std::string mExecutablePathAndName; // full path + Filename of .exe |
@@ -140,8 +149,9 @@ protected: | |||
140 | std::string mChatLogsDir; // Location for chat logs. | 149 | std::string mChatLogsDir; // Location for chat logs. |
141 | std::string mCAFile; // Location of the TLS certificate authority PEM file. | 150 | std::string mCAFile; // Location of the TLS certificate authority PEM file. |
142 | std::string mTempDir; | 151 | std::string mTempDir; |
143 | std::string mCacheDir; | 152 | std::string mCacheDir; // cache directory as set by user preference |
144 | std::string mOSCacheDir; | 153 | std::string mDefaultCacheDir; // default cache diretory |
154 | std::string mOSCacheDir; // operating system cache dir | ||
145 | std::string mDirDelimiter; | 155 | std::string mDirDelimiter; |
146 | std::string mSkinDir; // Location for current skin info. | 156 | std::string mSkinDir; // Location for current skin info. |
147 | std::string mDefaultSkinDir; // Location for default skin info. | 157 | std::string mDefaultSkinDir; // Location for default skin info. |
diff --git a/linden/indra/llvfs/lldir_linux.cpp b/linden/indra/llvfs/lldir_linux.cpp index ce8806a..8ff8c5d 100644 --- a/linden/indra/llvfs/lldir_linux.cpp +++ b/linden/indra/llvfs/lldir_linux.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, |
diff --git a/linden/indra/llvfs/lldir_linux.h b/linden/indra/llvfs/lldir_linux.h index 09a27a7..20b408f 100644 --- a/linden/indra/llvfs/lldir_linux.h +++ b/linden/indra/llvfs/lldir_linux.h | |||
@@ -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, |
diff --git a/linden/indra/llvfs/lldir_mac.cpp b/linden/indra/llvfs/lldir_mac.cpp index f61fa74..6d5dcf3 100644 --- a/linden/indra/llvfs/lldir_mac.cpp +++ b/linden/indra/llvfs/lldir_mac.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, |
diff --git a/linden/indra/llvfs/lldir_mac.h b/linden/indra/llvfs/lldir_mac.h index 8288bf8..28d48a0 100644 --- a/linden/indra/llvfs/lldir_mac.h +++ b/linden/indra/llvfs/lldir_mac.h | |||
@@ -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, |
diff --git a/linden/indra/llvfs/lldir_solaris.cpp b/linden/indra/llvfs/lldir_solaris.cpp index adbe747..9553d92 100644 --- a/linden/indra/llvfs/lldir_solaris.cpp +++ b/linden/indra/llvfs/lldir_solaris.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, |
@@ -36,14 +37,13 @@ | |||
36 | #include "llrand.h" | 37 | #include "llrand.h" |
37 | #include <sys/types.h> | 38 | #include <sys/types.h> |
38 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
39 | #include <fcntl.h> | ||
40 | #include <sys/param.h> | ||
41 | #include <unistd.h> | 40 | #include <unistd.h> |
42 | #include <glob.h> | 41 | #include <glob.h> |
43 | #include <pwd.h> | 42 | #include <pwd.h> |
44 | #include <sys/utsname.h> | 43 | #include <sys/utsname.h> |
45 | #define _STRUCTURED_PROC 1 | 44 | #define _STRUCTURED_PROC 1 |
46 | #include <sys/procfs.h> | 45 | #include <sys/procfs.h> |
46 | #include <fcntl.h> | ||
47 | 47 | ||
48 | static std::string getCurrentUserHome(char* fallback) | 48 | static std::string getCurrentUserHome(char* fallback) |
49 | { | 49 | { |
@@ -82,7 +82,16 @@ LLDir_Solaris::LLDir_Solaris() | |||
82 | mDirp = NULL; | 82 | mDirp = NULL; |
83 | 83 | ||
84 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ | 84 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ |
85 | getcwd(tmp_str, LL_MAX_PATH); | 85 | if (getcwd(tmp_str, LL_MAX_PATH) == NULL) |
86 | { | ||
87 | strcpy(tmp_str, "/tmp"); | ||
88 | llwarns << "Could not get current directory; changing to " | ||
89 | << tmp_str << llendl; | ||
90 | if (chdir(tmp_str) == -1) | ||
91 | { | ||
92 | llerrs << "Could not change directory to " << tmp_str << llendl; | ||
93 | } | ||
94 | } | ||
86 | 95 | ||
87 | mExecutableFilename = ""; | 96 | mExecutableFilename = ""; |
88 | mExecutablePathAndName = ""; | 97 | mExecutablePathAndName = ""; |
@@ -121,20 +130,35 @@ LLDir_Solaris::LLDir_Solaris() | |||
121 | return; | 130 | return; |
122 | } | 131 | } |
123 | 132 | ||
133 | char *p = execpath; // nuke trash in link, if any exists | ||
134 | int i = 0; | ||
135 | while(*p != NULL && ++i < LL_MAX_PATH && isprint((int)(*p++))); | ||
136 | *p = NULL; | ||
137 | |||
124 | mExecutablePathAndName = strdup(execpath); | 138 | mExecutablePathAndName = strdup(execpath); |
125 | llinfos << "mExecutablePathAndName = [" << mExecutablePathAndName << "]" << llendl; | 139 | llinfos << "mExecutablePathAndName = [" << mExecutablePathAndName << "]" << llendl; |
126 | 140 | ||
141 | //NOTE: Why force people to cd into the package directory? | ||
142 | // Look for SECONDLIFE env variable and use it, if set. | ||
143 | |||
144 | char *dcf = getenv("SECONDLIFE"); | ||
145 | if(dcf != NULL){ | ||
146 | (void)strcpy(path, dcf); | ||
147 | (void)strcat(path, "/bin"); //NOTE: make sure we point at the bin | ||
148 | mExecutableDir = strdup(path); | ||
149 | }else{ | ||
127 | // plunk a null at last '/' to get exec dir | 150 | // plunk a null at last '/' to get exec dir |
128 | char *s = execpath + strlen(execpath) -1; | 151 | char *s = execpath + strlen(execpath) -1; |
129 | while(*s != '/' && s != execpath){ | 152 | while(*s != '/' && s != execpath){ |
130 | --s; | 153 | --s; |
131 | } | 154 | } |
132 | 155 | ||
133 | if(s != execpath){ | 156 | if(s != execpath){ |
134 | *s = (char)NULL; | 157 | *s = (char)NULL; |
135 | 158 | ||
136 | mExecutableDir = strdup(execpath); | 159 | mExecutableDir = strdup(execpath); |
137 | llinfos << "mExecutableDir = [" << mExecutableDir << "]" << llendl; | 160 | llinfos << "mExecutableDir = [" << mExecutableDir << "]" << llendl; |
161 | } | ||
138 | } | 162 | } |
139 | 163 | ||
140 | // *TODO: don't use /tmp, use $HOME/.secondlife/tmp or something. | 164 | // *TODO: don't use /tmp, use $HOME/.secondlife/tmp or something. |
@@ -354,12 +378,16 @@ void LLDir_Solaris::getRandomFileInDir(const std::string &dirname, const std::st | |||
354 | std::string LLDir_Solaris::getCurPath() | 378 | std::string LLDir_Solaris::getCurPath() |
355 | { | 379 | { |
356 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ | 380 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ |
357 | getcwd(tmp_str, LL_MAX_PATH); | 381 | if (getcwd(tmp_str, LL_MAX_PATH) == NULL) |
382 | { | ||
383 | llwarns << "Could not get current directory" << llendl; | ||
384 | tmp_str[0] = '\0'; | ||
385 | } | ||
358 | return tmp_str; | 386 | return tmp_str; |
359 | } | 387 | } |
360 | 388 | ||
361 | 389 | ||
362 | BOOL LLDir_Solaris::fileExists(const std::string &filename) | 390 | BOOL LLDir_Solaris::fileExists(const std::string &filename) const |
363 | { | 391 | { |
364 | struct stat stat_data; | 392 | struct stat stat_data; |
365 | // Check the age of the file | 393 | // Check the age of the file |
diff --git a/linden/indra/llvfs/lldir_solaris.h b/linden/indra/llvfs/lldir_solaris.h index dea397d..139754b 100644 --- a/linden/indra/llvfs/lldir_solaris.h +++ b/linden/indra/llvfs/lldir_solaris.h | |||
@@ -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, |
@@ -49,7 +50,7 @@ public: | |||
49 | virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); | 50 | virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); |
50 | virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); | 51 | virtual BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap); |
51 | virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname); | 52 | virtual void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname); |
52 | /*virtual*/ BOOL fileExists(const std::string &filename); | 53 | /*virtual*/ BOOL fileExists(const std::string &filename) const; |
53 | 54 | ||
54 | private: | 55 | private: |
55 | DIR *mDirp; | 56 | DIR *mDirp; |
diff --git a/linden/indra/llvfs/lldir_win32.cpp b/linden/indra/llvfs/lldir_win32.cpp index 8703a0f..19b9bcc 100644 --- a/linden/indra/llvfs/lldir_win32.cpp +++ b/linden/indra/llvfs/lldir_win32.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, |
@@ -58,14 +59,18 @@ LLDir_Win32::LLDir_Win32() | |||
58 | 59 | ||
59 | mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); | 60 | mOSUserDir = utf16str_to_utf8str(llutf16string(w_str)); |
60 | 61 | ||
61 | // Local Settings\Application Data is where cache files should | 62 | // We want cache files to go on the local disk, even if the |
62 | // go, they don't get copied to the server if the user moves his | 63 | // user is on a network with a "roaming profile". |
63 | // profile around on the network. JC | ||
64 | // | 64 | // |
65 | // TODO: patch the installer to remove old cache files on update, then | 65 | // On XP this is: |
66 | // enable this code. | 66 | // C:\Docments and Settings\James\Local Settings\Application Data |
67 | //SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); | 67 | // On Vista this is: |
68 | //mOSUserCacheDir = utf16str_to_utf8str(llutf16string(w_str)); | 68 | // C:\Users\James\AppData\Local |
69 | // | ||
70 | // We used to store the cache in AppData\Roaming, and the installer | ||
71 | // cleans up that version on upgrade. JC | ||
72 | SHGetSpecialFolderPath(NULL, w_str, CSIDL_LOCAL_APPDATA, TRUE); | ||
73 | mOSCacheDir = utf16str_to_utf8str(llutf16string(w_str)); | ||
69 | 74 | ||
70 | if (GetTempPath(MAX_PATH, w_str)) | 75 | if (GetTempPath(MAX_PATH, w_str)) |
71 | { | 76 | { |
@@ -124,6 +129,20 @@ LLDir_Win32::LLDir_Win32() | |||
124 | mAppRODataDir = getCurPath(); | 129 | mAppRODataDir = getCurPath(); |
125 | else | 130 | else |
126 | mAppRODataDir = mExecutableDir; | 131 | mAppRODataDir = mExecutableDir; |
132 | |||
133 | |||
134 | // Build the default cache directory | ||
135 | mDefaultCacheDir = buildSLOSCacheDir(); | ||
136 | |||
137 | // Make sure it exists | ||
138 | int res = LLFile::mkdir(mDefaultCacheDir); | ||
139 | if (res == -1) | ||
140 | { | ||
141 | if (errno != EEXIST) | ||
142 | { | ||
143 | llwarns << "Couldn't create LL_PATH_CACHE dir " << mDefaultCacheDir << llendl; | ||
144 | } | ||
145 | } | ||
127 | } | 146 | } |
128 | 147 | ||
129 | LLDir_Win32::~LLDir_Win32() | 148 | LLDir_Win32::~LLDir_Win32() |
diff --git a/linden/indra/llvfs/lldir_win32.h b/linden/indra/llvfs/lldir_win32.h index 25bb276..8710ca5 100644 --- a/linden/indra/llvfs/lldir_win32.h +++ b/linden/indra/llvfs/lldir_win32.h | |||
@@ -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, |
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 | ||
77 | LLLFSThread::~LLLFSThread() | 82 | LLLFSThread::~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 |
diff --git a/linden/indra/llvfs/lllfsthread.h b/linden/indra/llvfs/lllfsthread.h index a344282..5a11cb3 100644 --- a/linden/indra/llvfs/lllfsthread.h +++ b/linden/indra/llvfs/lllfsthread.h | |||
@@ -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, |
diff --git a/linden/indra/llvfs/llpidlock.cpp b/linden/indra/llvfs/llpidlock.cpp new file mode 100755 index 0000000..93ac120 --- /dev/null +++ b/linden/indra/llvfs/llpidlock.cpp | |||
@@ -0,0 +1,269 @@ | |||
1 | /** | ||
2 | * @file llformat.cpp | ||
3 | * @date January 2007 | ||
4 | * @brief string formatting utility | ||
5 | * | ||
6 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2007-2009, Linden Research, Inc. | ||
9 | * | ||
10 | * Second Life Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
12 | * to you under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
16 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
17 | * | ||
18 | * There are special exceptions to the terms and conditions of the GPL as | ||
19 | * it is applied to this Source Code. View the full text of the exception | ||
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
21 | * online at | ||
22 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
23 | * | ||
24 | * By copying, modifying or distributing this software, you acknowledge | ||
25 | * that you have read and understood your obligations described above, | ||
26 | * and agree to abide by those obligations. | ||
27 | * | ||
28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
30 | * COMPLETENESS OR PERFORMANCE. | ||
31 | * $/LicenseInfo$ | ||
32 | */ | ||
33 | |||
34 | #include "linden_common.h" | ||
35 | |||
36 | #include "llpidlock.h" | ||
37 | #include "lldir.h" | ||
38 | #include "llsd.h" | ||
39 | #include "llsdserialize.h" | ||
40 | #include "llnametable.h" | ||
41 | #include "llframetimer.h" | ||
42 | |||
43 | #if LL_WINDOWS //For windows platform. | ||
44 | bool isProcessAlive(U32 pid) | ||
45 | { | ||
46 | return (bool) GetProcessVersion((DWORD)pid); | ||
47 | } | ||
48 | |||
49 | #else //Everyone Else | ||
50 | bool isProcessAlive(U32 pid) | ||
51 | { | ||
52 | return (bool) kill( (pid_t)pid, 0); | ||
53 | } | ||
54 | #endif //Everyone else. | ||
55 | |||
56 | |||
57 | |||
58 | class LLPidLockFile | ||
59 | { | ||
60 | public: | ||
61 | LLPidLockFile( ) : | ||
62 | mSaving(FALSE), mWaiting(FALSE), | ||
63 | mClean(TRUE), mPID(getpid()) | ||
64 | { | ||
65 | mLockName = gDirUtilp->getTempDir() + "/savelock"; | ||
66 | } | ||
67 | bool requestLock(LLNameTable<void *> *name_table, bool autosave, | ||
68 | bool force_immediate=FALSE, F32 timeout=300.0); | ||
69 | bool checkLock(); | ||
70 | void releaseLock(); | ||
71 | |||
72 | private: | ||
73 | void writeLockFile(LLSD pids); | ||
74 | public: | ||
75 | static LLPidLockFile& instance(); // return the singleton black list file | ||
76 | |||
77 | bool mAutosave; | ||
78 | bool mSaving; | ||
79 | bool mWaiting; | ||
80 | LLFrameTimer mTimer; | ||
81 | U32 mPID; | ||
82 | std::string mLockName; | ||
83 | std::string mSaveName; | ||
84 | LLSD mPIDS_sd; | ||
85 | LLNameTable<void*> *mNameTable; | ||
86 | bool mClean; | ||
87 | }; | ||
88 | |||
89 | LLPidLockFile& LLPidLockFile::instance() | ||
90 | { | ||
91 | static LLPidLockFile the_file; | ||
92 | return the_file; | ||
93 | } | ||
94 | |||
95 | void LLPidLockFile::writeLockFile(LLSD pids) | ||
96 | { | ||
97 | llofstream ofile(mLockName); | ||
98 | |||
99 | if (!LLSDSerialize::toXML(pids,ofile)) | ||
100 | { | ||
101 | llwarns << "Unable to write concurrent save lock file." << llendl; | ||
102 | } | ||
103 | ofile.close(); | ||
104 | } | ||
105 | |||
106 | bool LLPidLockFile::requestLock(LLNameTable<void *> *name_table, bool autosave, | ||
107 | bool force_immediate, F32 timeout) | ||
108 | { | ||
109 | bool readyToSave = FALSE; | ||
110 | |||
111 | if (mSaving) return FALSE; //Bail out if we're currently saving. Will not queue another save. | ||
112 | |||
113 | if (!mWaiting){ | ||
114 | mNameTable=name_table; | ||
115 | mAutosave = autosave; | ||
116 | } | ||
117 | |||
118 | LLSD out_pids; | ||
119 | out_pids.append( (LLSD::Integer)mPID ); | ||
120 | |||
121 | llifstream ifile(mLockName); | ||
122 | |||
123 | if (ifile.is_open()) | ||
124 | { //If file exists, we need to decide whether or not to continue. | ||
125 | if ( force_immediate | ||
126 | || mTimer.hasExpired() ) //Only deserialize if we REALLY need to. | ||
127 | { | ||
128 | |||
129 | LLSD in_pids; | ||
130 | |||
131 | LLSDSerialize::fromXML(in_pids, ifile); | ||
132 | |||
133 | //Clean up any dead PIDS that might be in there. | ||
134 | for (LLSD::array_iterator i=in_pids.beginArray(); | ||
135 | i !=in_pids.endArray(); | ||
136 | ++i) | ||
137 | { | ||
138 | U32 stored_pid=(*i).asInteger(); | ||
139 | |||
140 | if (isProcessAlive(stored_pid)) | ||
141 | { | ||
142 | out_pids.append( (*i) ); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | readyToSave=TRUE; | ||
147 | } | ||
148 | ifile.close(); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | readyToSave=TRUE; | ||
153 | } | ||
154 | |||
155 | if (!mWaiting) //Not presently waiting to save. Queue up. | ||
156 | { | ||
157 | mTimer.resetWithExpiry(timeout); | ||
158 | mWaiting=TRUE; | ||
159 | } | ||
160 | |||
161 | if (readyToSave) | ||
162 | { //Potential race condition won't kill us. Ignore it. | ||
163 | writeLockFile(out_pids); | ||
164 | mSaving=TRUE; | ||
165 | } | ||
166 | |||
167 | return readyToSave; | ||
168 | } | ||
169 | |||
170 | bool LLPidLockFile::checkLock() | ||
171 | { | ||
172 | return mWaiting; | ||
173 | } | ||
174 | |||
175 | void LLPidLockFile::releaseLock() | ||
176 | { | ||
177 | llifstream ifile(mLockName); | ||
178 | LLSD in_pids; | ||
179 | LLSD out_pids; | ||
180 | bool write_file=FALSE; | ||
181 | |||
182 | LLSDSerialize::fromXML(in_pids, ifile); | ||
183 | |||
184 | //Clean up this PID and any dead ones. | ||
185 | for (LLSD::array_iterator i=in_pids.beginArray(); | ||
186 | i !=in_pids.endArray(); | ||
187 | ++i) | ||
188 | { | ||
189 | U32 stored_pid=(*i).asInteger(); | ||
190 | |||
191 | if (stored_pid != mPID && isProcessAlive(stored_pid)) | ||
192 | { | ||
193 | out_pids.append( (*i) ); | ||
194 | write_file=TRUE; | ||
195 | } | ||
196 | } | ||
197 | ifile.close(); | ||
198 | |||
199 | if (write_file) | ||
200 | { | ||
201 | writeLockFile(out_pids); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | unlink(mLockName.c_str()); | ||
206 | } | ||
207 | |||
208 | mSaving=FALSE; | ||
209 | mWaiting=FALSE; | ||
210 | } | ||
211 | |||
212 | //LLPidLock | ||
213 | |||
214 | void LLPidLock::initClass() { | ||
215 | (void) LLPidLockFile::instance(); | ||
216 | } | ||
217 | |||
218 | bool LLPidLock::checkLock() | ||
219 | { | ||
220 | return LLPidLockFile::instance().checkLock(); | ||
221 | } | ||
222 | |||
223 | bool LLPidLock::requestLock(LLNameTable<void *> *name_table, bool autosave, | ||
224 | bool force_immediate, F32 timeout) | ||
225 | { | ||
226 | return LLPidLockFile::instance().requestLock(name_table,autosave,force_immediate,timeout); | ||
227 | } | ||
228 | |||
229 | void LLPidLock::releaseLock() | ||
230 | { | ||
231 | return LLPidLockFile::instance().releaseLock(); | ||
232 | } | ||
233 | |||
234 | bool LLPidLock::isClean() | ||
235 | { | ||
236 | return LLPidLockFile::instance().mClean; | ||
237 | } | ||
238 | |||
239 | //getters | ||
240 | LLNameTable<void *> * LLPidLock::getNameTable() | ||
241 | { | ||
242 | return LLPidLockFile::instance().mNameTable; | ||
243 | } | ||
244 | |||
245 | bool LLPidLock::getAutosave() | ||
246 | { | ||
247 | return LLPidLockFile::instance().mAutosave; | ||
248 | } | ||
249 | |||
250 | bool LLPidLock::getClean() | ||
251 | { | ||
252 | return LLPidLockFile::instance().mClean; | ||
253 | } | ||
254 | |||
255 | std::string LLPidLock::getSaveName() | ||
256 | { | ||
257 | return LLPidLockFile::instance().mSaveName; | ||
258 | } | ||
259 | |||
260 | //setters | ||
261 | void LLPidLock::setClean(bool clean) | ||
262 | { | ||
263 | LLPidLockFile::instance().mClean=clean; | ||
264 | } | ||
265 | |||
266 | void LLPidLock::setSaveName(std::string savename) | ||
267 | { | ||
268 | LLPidLockFile::instance().mSaveName=savename; | ||
269 | } | ||
diff --git a/linden/indra/llvfs/llpidlock.h b/linden/indra/llvfs/llpidlock.h new file mode 100755 index 0000000..42aee4d --- /dev/null +++ b/linden/indra/llvfs/llpidlock.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /** | ||
2 | * @file llpidlock.h | ||
3 | * @brief System information debugging classes. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2001-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
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 | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #ifndef LL_PIDLOCK_H | ||
34 | #define LL_PIDLOCK_H | ||
35 | #include "llnametable.h" | ||
36 | |||
37 | class LLSD; | ||
38 | class LLFrameTimer; | ||
39 | |||
40 | #if LL_WINDOWS //For windows platform. | ||
41 | |||
42 | #include <windows.h> | ||
43 | |||
44 | #define getpid GetCurrentProcessId | ||
45 | |||
46 | #else //Everyone Else | ||
47 | |||
48 | #include <signal.h> | ||
49 | |||
50 | #endif //Everyone else. | ||
51 | |||
52 | namespace LLPidLock | ||
53 | { | ||
54 | void initClass(); // { (void) LLPidLockFile::instance(); } | ||
55 | |||
56 | bool requestLock( LLNameTable<void *> *name_table=NULL, bool autosave=TRUE, | ||
57 | bool force_immediate=FALSE, F32 timeout=300.0); | ||
58 | bool checkLock(); | ||
59 | void releaseLock(); | ||
60 | bool isClean(); | ||
61 | |||
62 | //getters | ||
63 | LLNameTable<void *> * getNameTable(); | ||
64 | bool getAutosave(); | ||
65 | bool getClean(); | ||
66 | std::string getSaveName(); | ||
67 | |||
68 | //setters | ||
69 | void setClean(bool clean); | ||
70 | void setSaveName(std::string savename); | ||
71 | }; | ||
72 | |||
73 | #endif // LL_PIDLOCK_H | ||
diff --git a/linden/indra/llvfs/llvfile.cpp b/linden/indra/llvfs/llvfile.cpp index 085c36c..6b1563b 100644 --- a/linden/indra/llvfs/llvfile.cpp +++ b/linden/indra/llvfs/llvfile.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, |
diff --git a/linden/indra/llvfs/llvfile.h b/linden/indra/llvfs/llvfile.h index 16fa779..5f69a41 100644 --- a/linden/indra/llvfs/llvfile.h +++ b/linden/indra/llvfs/llvfile.h | |||
@@ -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, |
diff --git a/linden/indra/llvfs/llvfs.cpp b/linden/indra/llvfs/llvfs.cpp index d6c9278..e5ffce4 100644 --- a/linden/indra/llvfs/llvfs.cpp +++ b/linden/indra/llvfs/llvfs.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, |
@@ -231,7 +232,7 @@ struct LLVFSFileBlock_less | |||
231 | 232 | ||
232 | const S32 LLVFSFileBlock::SERIAL_SIZE = 34; | 233 | const S32 LLVFSFileBlock::SERIAL_SIZE = 34; |
233 | 234 | ||
234 | 235 | ||
235 | LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash) | 236 | LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash) |
236 | : mRemoveAfterCrash(remove_after_crash) | 237 | : mRemoveAfterCrash(remove_after_crash) |
237 | { | 238 | { |
@@ -399,6 +400,12 @@ LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename | |||
399 | mDataFP = NULL; | 400 | mDataFP = NULL; |
400 | LLFile::remove( mDataFilename ); | 401 | LLFile::remove( mDataFilename ); |
401 | 402 | ||
403 | LL_WARNS("VFS") << "Deleted corrupt VFS files " | ||
404 | << mDataFilename | ||
405 | << " and " | ||
406 | << mIndexFilename | ||
407 | << LL_ENDL; | ||
408 | |||
402 | mValid = VFSVALID_BAD_CORRUPT; | 409 | mValid = VFSVALID_BAD_CORRUPT; |
403 | return; | 410 | return; |
404 | } | 411 | } |
@@ -504,6 +511,13 @@ LLVFS::LLVFS(const std::string& index_filename, const std::string& data_filename | |||
504 | << " ID " << cur_file_block->mFileID | 511 | << " ID " << cur_file_block->mFileID |
505 | << " type " << cur_file_block->mFileType | 512 | << " type " << cur_file_block->mFileType |
506 | << LL_ENDL; | 513 | << LL_ENDL; |
514 | |||
515 | LL_WARNS("VFS") << "Deleted corrupt VFS files " | ||
516 | << mDataFilename | ||
517 | << " and " | ||
518 | << mIndexFilename | ||
519 | << LL_ENDL; | ||
520 | |||
507 | mValid = VFSVALID_BAD_CORRUPT; | 521 | mValid = VFSVALID_BAD_CORRUPT; |
508 | return; | 522 | return; |
509 | } | 523 | } |
@@ -717,8 +731,14 @@ S32 LLVFS::getMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type | |||
717 | 731 | ||
718 | BOOL LLVFS::checkAvailable(S32 max_size) | 732 | BOOL LLVFS::checkAvailable(S32 max_size) |
719 | { | 733 | { |
734 | lockData(); | ||
735 | |||
720 | blocks_length_map_t::iterator iter = mFreeBlocksByLength.lower_bound(max_size); // first entry >= size | 736 | blocks_length_map_t::iterator iter = mFreeBlocksByLength.lower_bound(max_size); // first entry >= size |
721 | return (iter == mFreeBlocksByLength.end()) ? FALSE : TRUE; | 737 | const BOOL res(iter == mFreeBlocksByLength.end() ? FALSE : TRUE); |
738 | |||
739 | unlockData(); | ||
740 | |||
741 | return res; | ||
722 | } | 742 | } |
723 | 743 | ||
724 | BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type, S32 max_size) | 744 | BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type, S32 max_size) |
@@ -824,13 +844,20 @@ BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type | |||
824 | 844 | ||
825 | if (free_block) | 845 | if (free_block) |
826 | { | 846 | { |
847 | // Save location where data is going, useFreeSpace will move free_block->mLocation; | ||
848 | U32 new_data_location = free_block->mLocation; | ||
849 | |||
850 | //mark the free block as used so it does not | ||
851 | //interfere with other operations such as addFreeBlock | ||
852 | useFreeSpace(free_block, max_size); // useFreeSpace takes ownership (and may delete) free_block | ||
853 | |||
827 | if (block->mLength > 0) | 854 | if (block->mLength > 0) |
828 | { | 855 | { |
829 | // create a new free block where this file used to be | 856 | // create a new free block where this file used to be |
830 | LLVFSBlock *new_free_block = new LLVFSBlock(block->mLocation, block->mLength); | 857 | LLVFSBlock *new_free_block = new LLVFSBlock(block->mLocation, block->mLength); |
831 | 858 | ||
832 | addFreeBlock(new_free_block); | 859 | addFreeBlock(new_free_block); |
833 | 860 | ||
834 | if (block->mSize > 0) | 861 | if (block->mSize > 0) |
835 | { | 862 | { |
836 | // move the file into the new block | 863 | // move the file into the new block |
@@ -838,7 +865,7 @@ BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type | |||
838 | fseek(mDataFP, block->mLocation, SEEK_SET); | 865 | fseek(mDataFP, block->mLocation, SEEK_SET); |
839 | if (fread(buffer, block->mSize, 1, mDataFP) == 1) | 866 | if (fread(buffer, block->mSize, 1, mDataFP) == 1) |
840 | { | 867 | { |
841 | fseek(mDataFP, free_block->mLocation, SEEK_SET); | 868 | fseek(mDataFP, new_data_location, SEEK_SET); |
842 | if (fwrite(buffer, block->mSize, 1, mDataFP) != 1) | 869 | if (fwrite(buffer, block->mSize, 1, mDataFP) != 1) |
843 | { | 870 | { |
844 | llwarns << "Short write" << llendl; | 871 | llwarns << "Short write" << llendl; |
@@ -851,13 +878,10 @@ BOOL LLVFS::setMaxSize(const LLUUID &file_id, const LLAssetType::EType file_type | |||
851 | } | 878 | } |
852 | } | 879 | } |
853 | 880 | ||
854 | block->mLocation = free_block->mLocation; | 881 | block->mLocation = new_data_location; |
855 | 882 | ||
856 | block->mLength = max_size; | 883 | block->mLength = max_size; |
857 | 884 | ||
858 | // Must call useFreeSpace before sync(), as sync() | ||
859 | // unlocks data structures. | ||
860 | useFreeSpace(free_block, max_size); | ||
861 | 885 | ||
862 | sync(block); | 886 | sync(block); |
863 | 887 | ||
@@ -1072,14 +1096,14 @@ S32 LLVFS::getData(const LLUUID &file_id, const LLAssetType::EType file_type, U8 | |||
1072 | } | 1096 | } |
1073 | } | 1097 | } |
1074 | 1098 | ||
1075 | unlockData(); | ||
1076 | |||
1077 | if (do_read) | 1099 | if (do_read) |
1078 | { | 1100 | { |
1079 | fseek(mDataFP, location, SEEK_SET); | 1101 | fseek(mDataFP, location, SEEK_SET); |
1080 | bytesread = (S32)fread(buffer, 1, length, mDataFP); | 1102 | bytesread = (S32)fread(buffer, 1, length, mDataFP); |
1081 | } | 1103 | } |
1082 | 1104 | ||
1105 | unlockData(); | ||
1106 | |||
1083 | return bytesread; | 1107 | return bytesread; |
1084 | } | 1108 | } |
1085 | 1109 | ||
@@ -1144,8 +1168,6 @@ S32 LLVFS::storeData(const LLUUID &file_id, const LLAssetType::EType file_type, | |||
1144 | } | 1168 | } |
1145 | U32 file_location = location + block->mLocation; | 1169 | U32 file_location = location + block->mLocation; |
1146 | 1170 | ||
1147 | unlockData(); | ||
1148 | |||
1149 | fseek(mDataFP, file_location, SEEK_SET); | 1171 | fseek(mDataFP, file_location, SEEK_SET); |
1150 | S32 write_len = (S32)fwrite(buffer, 1, length, mDataFP); | 1172 | S32 write_len = (S32)fwrite(buffer, 1, length, mDataFP); |
1151 | if (write_len != length) | 1173 | if (write_len != length) |
@@ -1154,7 +1176,6 @@ S32 LLVFS::storeData(const LLUUID &file_id, const LLAssetType::EType file_type, | |||
1154 | } | 1176 | } |
1155 | // fflush(mDataFP); | 1177 | // fflush(mDataFP); |
1156 | 1178 | ||
1157 | lockData(); | ||
1158 | if (location + length > block->mSize) | 1179 | if (location + length > block->mSize) |
1159 | { | 1180 | { |
1160 | block->mSize = location + write_len; | 1181 | block->mSize = location + write_len; |
@@ -1403,7 +1424,7 @@ void LLVFS::addFreeBlock(LLVFSBlock *block) | |||
1403 | // } | 1424 | // } |
1404 | //} | 1425 | //} |
1405 | 1426 | ||
1406 | 1427 | // length bytes from free_block are going to be used (so they are no longer free) | |
1407 | void LLVFS::useFreeSpace(LLVFSBlock *free_block, S32 length) | 1428 | void LLVFS::useFreeSpace(LLVFSBlock *free_block, S32 length) |
1408 | { | 1429 | { |
1409 | if (free_block->mLength == length) | 1430 | if (free_block->mLength == length) |
@@ -1486,8 +1507,6 @@ void LLVFS::sync(LLVFSFileBlock *block, BOOL remove) | |||
1486 | block->serialize(buffer); | 1507 | block->serialize(buffer); |
1487 | } | 1508 | } |
1488 | 1509 | ||
1489 | unlockData(); | ||
1490 | |||
1491 | // If set_index_to_end, file pointer is already at seek_pos | 1510 | // If set_index_to_end, file pointer is already at seek_pos |
1492 | // and we don't need to do anything. Only seek if not at end. | 1511 | // and we don't need to do anything. Only seek if not at end. |
1493 | if (!set_index_to_end) | 1512 | if (!set_index_to_end) |
@@ -1499,11 +1518,10 @@ void LLVFS::sync(LLVFSFileBlock *block, BOOL remove) | |||
1499 | { | 1518 | { |
1500 | llwarns << "Short write" << llendl; | 1519 | llwarns << "Short write" << llendl; |
1501 | } | 1520 | } |
1502 | 1521 | ||
1522 | // *NOTE: Why was this commented out? | ||
1503 | // fflush(mIndexFP); | 1523 | // fflush(mIndexFP); |
1504 | 1524 | ||
1505 | lockData(); | ||
1506 | |||
1507 | return; | 1525 | return; |
1508 | } | 1526 | } |
1509 | 1527 | ||
@@ -2069,9 +2087,11 @@ void LLVFS::dumpFiles() | |||
2069 | std::string extension = get_extension(type); | 2087 | std::string extension = get_extension(type); |
2070 | std::string filename = id.asString() + extension; | 2088 | std::string filename = id.asString() + extension; |
2071 | llinfos << " Writing " << filename << llendl; | 2089 | llinfos << " Writing " << filename << llendl; |
2072 | apr_file_t* file = ll_apr_file_open(filename, LL_APR_WB); | 2090 | |
2073 | ll_apr_file_write(file, buffer, size); | 2091 | LLAPRFile outfile ; |
2074 | apr_file_close(file); | 2092 | outfile.open(filename, LL_APR_WB); |
2093 | outfile.write(buffer, size); | ||
2094 | outfile.close(); | ||
2075 | delete[] buffer; | 2095 | delete[] buffer; |
2076 | files_extracted++; | 2096 | files_extracted++; |
2077 | } | 2097 | } |
diff --git a/linden/indra/llvfs/llvfs.h b/linden/indra/llvfs/llvfs.h index b31ec89..a68c8f4 100644 --- a/linden/indra/llvfs/llvfs.h +++ b/linden/indra/llvfs/llvfs.h | |||
@@ -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, |
diff --git a/linden/indra/llvfs/llvfsthread.cpp b/linden/indra/llvfs/llvfsthread.cpp index 599c00e..69da4b7 100644 --- a/linden/indra/llvfs/llvfsthread.cpp +++ b/linden/indra/llvfs/llvfsthread.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, |
diff --git a/linden/indra/llvfs/llvfsthread.h b/linden/indra/llvfs/llvfsthread.h index b38a788..0a9786e 100644 --- a/linden/indra/llvfs/llvfsthread.h +++ b/linden/indra/llvfs/llvfsthread.h | |||
@@ -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, |