[Box Backup-commit] COMMIT r1287 - in box/chris/general/lib: common server

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Wed Feb 14 23:16:49 GMT 2007


Author: chris
Date: 2007-02-14 23:16:49 +0000 (Wed, 14 Feb 2007)
New Revision: 1287

Modified:
   box/chris/general/lib/common/Test.h
   box/chris/general/lib/server/ServerControl.h
Log:
Remove newly added KillServer and HUPServer from Test.h, merge with
existing versions in ServerControl.h instead.

Add BBSTORED and BBSTOREACCOUNTS command paths with Windows and Unix
versions.


Modified: box/chris/general/lib/common/Test.h
===================================================================
--- box/chris/general/lib/common/Test.h	2007-02-13 23:20:22 UTC (rev 1286)
+++ box/chris/general/lib/common/Test.h	2007-02-14 23:16:49 UTC (rev 1287)
@@ -259,49 +259,6 @@
 #define TestRemoteProcessMemLeaks(filename) \
 	TestRemoteProcessMemLeaksFunc(filename, __FILE__, __LINE__)
 
-inline bool HUPServer(int pid)
-{
-	if(pid == 0) return false;
-	return ::kill(pid, SIGHUP) != -1;
-}
-
-inline bool KillServerInternal(int pid)
-{
-	if(pid == 0 || pid == -1) return false;
-	TEST_THAT(::kill(pid, SIGTERM) != -1);
-}
-
-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 TestRemoteProcessMemLeaksFunc(const char *filename,
 	const char* file, int line)
 {
@@ -349,14 +306,18 @@
 }
 
 #ifdef WIN32
-#define BBACKUPCTL   "..\\..\\bin\\bbackupctl\\bbackupctl"
-#define BBACKUPD     "..\\..\\bin\\bbackupd\\bbackupd"
-#define BBACKUPQUERY "..\\..\\bin\\bbackupquery\\bbackupquery.exe"
+#define BBACKUPCTL      "..\\..\\bin\\bbackupctl\\bbackupctl.exe"
+#define BBACKUPD        "..\\..\\bin\\bbackupd\\bbackupd.exe"
+#define BBSTORED        "..\\..\\bin\\bbstored\\bbstored.exe"
+#define BBACKUPQUERY    "..\\..\\bin\\bbackupquery\\bbackupquery.exe"
+#define BBSTOREACCOUNTS "..\\..\\bin\\bbstoreaccounts\\bbstoreaccounts.exe"
 #define TEST_RETURN(actual, expected) TEST_THAT(actual == expected);
 #else
-#define BBACKUPCTL   "../../bin/bbackupctl/bbackupctl"
-#define BBACKUPD     "../../bin/bbackupd/bbackupd"
-#define BBACKUPQUERY "../../bin/bbackupquery/bbackupquery"
+#define BBACKUPCTL      "../../bin/bbackupctl/bbackupctl"
+#define BBACKUPD        "../../bin/bbackupd/bbackupd"
+#define BBSTORED        "../../bin/bbackupd/bbstored"
+#define BBACKUPQUERY    "../../bin/bbackupquery/bbackupquery"
+#define BBSTOREACCOUNTS "../../bin/bbstoreaccounts/bbstoreaccounts"
 #define TEST_RETURN(actual, expected) TEST_THAT(actual == expected*256);
 #endif
 

Modified: box/chris/general/lib/server/ServerControl.h
===================================================================
--- box/chris/general/lib/server/ServerControl.h	2007-02-13 23:20:22 UTC (rev 1286)
+++ box/chris/general/lib/server/ServerControl.h	2007-02-14 23:16:49 UTC (rev 1287)
@@ -6,6 +6,7 @@
 #include "WinNamedPipeStream.h"
 #include "IOStreamGetLine.h"
 #include "BoxPortsAndFiles.h"
+#include "Test.h"
 
 static bool SendCommands(const std::string& rCmd)
 {
@@ -97,7 +98,7 @@
 	return SendCommands("reload");
 }
 
-inline bool KillServer(int pid)
+inline bool KillServerInternal(int pid)
 {
 	HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, false, pid);
 	if (hProcess == NULL)
@@ -116,9 +117,7 @@
 	}
 
 	CloseHandle(hProcess);
-
-	::sleep(1);
-	return !ServerIsAlive(pid);
+	return true;
 }
 
 #else // !WIN32
@@ -129,15 +128,47 @@
 	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);
+	bool killed = (::kill(pid, SIGTERM) != -1);
+	TEST_THAT(killed);
+	return killed;
 }
 
 #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);
+}
+
 #endif // SERVER_CONTROL_H




More information about the Boxbackup-commit mailing list