summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/rankings.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/rankings.cc')
-rw-r--r--net/disk_cache/rankings.cc49
1 files changed, 35 insertions, 14 deletions
diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc
index e3ff489..d786077 100644
--- a/net/disk_cache/rankings.cc
+++ b/net/disk_cache/rankings.cc
@@ -63,10 +63,20 @@ enum CrashLocation {
ON_REMOVE_3, ON_REMOVE_4, ON_REMOVE_5, ON_REMOVE_6, ON_REMOVE_7, ON_REMOVE_8
};
+void TerminateSelf() {
+#if defined(OS_WIN)
+ // Windows does more work on _exit() than we would like, so we force exit.
+ TerminateProcess(GetCurrentProcess(), 0);
+#elif defined(OS_POSIX)
+ // On POSIX, _exit() will terminate the process with minimal cleanup,
+ // and it is cleaner than killing.
+ _exit(0);
+#endif
+}
+
// Generates a crash on debug builds, acording to the value of g_rankings_crash.
// This used by crash_cache.exe to generate unit-test files.
void GenerateCrash(CrashLocation location) {
-#if defined(OS_WIN)
#ifndef NDEBUG
if (disk_cache::NO_CRASH == g_rankings_crash)
return;
@@ -75,26 +85,32 @@ void GenerateCrash(CrashLocation location) {
switch (g_rankings_crash) {
case disk_cache::INSERT_ONE_1:
case disk_cache::INSERT_LOAD_1:
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
+ default:
+ break;
}
break;
case ON_INSERT_2:
if (disk_cache::INSERT_EMPTY_1 == g_rankings_crash)
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
break;
case ON_INSERT_3:
switch (g_rankings_crash) {
case disk_cache::INSERT_EMPTY_2:
case disk_cache::INSERT_ONE_2:
case disk_cache::INSERT_LOAD_2:
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
+ default:
+ break;
}
break;
case ON_INSERT_4:
switch (g_rankings_crash) {
case disk_cache::INSERT_EMPTY_3:
case disk_cache::INSERT_ONE_3:
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
+ default:
+ break;
}
break;
case ON_REMOVE_1:
@@ -103,42 +119,48 @@ void GenerateCrash(CrashLocation location) {
case disk_cache::REMOVE_HEAD_1:
case disk_cache::REMOVE_TAIL_1:
case disk_cache::REMOVE_LOAD_1:
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
+ default:
+ break;
}
break;
case ON_REMOVE_2:
if (disk_cache::REMOVE_ONE_2 == g_rankings_crash)
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
break;
case ON_REMOVE_3:
if (disk_cache::REMOVE_ONE_3 == g_rankings_crash)
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
break;
case ON_REMOVE_4:
if (disk_cache::REMOVE_HEAD_2 == g_rankings_crash)
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
break;
case ON_REMOVE_5:
if (disk_cache::REMOVE_TAIL_2 == g_rankings_crash)
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
break;
case ON_REMOVE_6:
if (disk_cache::REMOVE_TAIL_3 == g_rankings_crash)
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
break;
case ON_REMOVE_7:
switch (g_rankings_crash) {
case disk_cache::REMOVE_ONE_4:
case disk_cache::REMOVE_LOAD_2:
case disk_cache::REMOVE_HEAD_3:
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
+ default:
+ break;
}
break;
case ON_REMOVE_8:
switch (g_rankings_crash) {
case disk_cache::REMOVE_HEAD_4:
case disk_cache::REMOVE_LOAD_3:
- TerminateProcess(GetCurrentProcess(), 0);
+ TerminateSelf();
+ default:
+ break;
}
break;
default:
@@ -146,7 +168,6 @@ void GenerateCrash(CrashLocation location) {
return;
}
#endif // NDEBUG
-#endif // OS_WIN
}
} // namespace