diff options
author | Chris Wilson <chris+github@qwirx.com> | 2006-10-18 19:39:04 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2006-10-18 19:39:04 +0000 |
commit | 6e725ef45d8800908e93b095bc33ede462c0dcef (patch) | |
tree | 85414ef04747fd9219a30be5bcfcbd111758309e /lib | |
parent | 17aeccfaa339e16e88cf9597730a6960accb9dfd (diff) |
Wait longer for server to die in KillServer (takes about 5 seconds on
my box). (refs #3)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/Test.h | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/lib/common/Test.h b/lib/common/Test.h index 35e9ba58..1312241d 100644 --- a/lib/common/Test.h +++ b/lib/common/Test.h @@ -227,7 +227,7 @@ bool SendCommands(const std::string& rCmd) return statusOk; } -inline bool ServerIsAlive() +inline bool ServerIsAlive(int pid) { return SendCommands(""); } @@ -237,11 +237,9 @@ inline bool HUPServer(int pid) return SendCommands("reload"); } -inline bool KillServer(int pid) +inline bool KillServerInternal(int pid) { TEST_THAT(SendCommands("terminate")); - ::sleep(1); - return !ServerIsAlive(); } #else // !WIN32 @@ -258,17 +256,45 @@ inline bool HUPServer(int pid) return ::kill(pid, SIGHUP) != -1; } -inline bool KillServer(int pid) +inline bool KillServerInternal(int pid) { if(pid == 0 || pid == -1) return false; - bool KilledOK = ::kill(pid, SIGTERM) != -1; - TEST_THAT(KilledOK); - ::sleep(1); - return !ServerIsAlive(pid); + TEST_THAT(::kill(pid, SIGTERM) != -1); } #endif // WIN32 +inline bool KillServer(int pid) +{ + KillServerInternal(pid); + + for (int i = 0; i < 30; i++) + { + if (!ServerIsAlive(pid)) break; + ::sleep(1); + if (!ServerIsAlive(pid)) break; + + if (i == 0) + { + printf("waiting for server to die"); + } + printf("."); + fflush(stdout); + } + + if (!ServerIsAlive(pid)) + { + printf("done.\n"); + } + else + { + printf("failed!\n"); + } + fflush(stdout); + + return !ServerIsAlive(pid); +} + inline void TestRemoteProcessMemLeaks(const char *filename) { #ifdef BOX_MEMORY_LEAK_TESTING |