[Box Backup-commit] COMMIT r1836 - box/chris/general/lib/server

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Fri Sep 14 23:12:28 BST 2007


Author: chris
Date: 2007-09-14 23:12:28 +0100 (Fri, 14 Sep 2007)
New Revision: 1836

Modified:
   box/chris/general/lib/server/ServerControl.h
Log:
Added function to set the named pipe name, for use by any test which calls
HUPServer() or SendCommands().


Modified: box/chris/general/lib/server/ServerControl.h
===================================================================
--- box/chris/general/lib/server/ServerControl.h	2007-09-14 22:11:30 UTC (rev 1835)
+++ box/chris/general/lib/server/ServerControl.h	2007-09-14 22:12:28 UTC (rev 1836)
@@ -9,17 +9,24 @@
 #include "IOStreamGetLine.h"
 #include "BoxPortsAndFiles.h"
 
+static std::string sPipeName;
+
+static void SetNamedPipeName(const std::string& rPipeName)
+{
+	sPipeName = rPipeName;
+}
+
 static bool SendCommands(const std::string& rCmd)
 {
 	WinNamedPipeStream connection;
 
 	try
 	{
-		connection.Connect(BOX_NAMED_PIPE_NAME);
+		connection.Connect(sPipeName);
 	}
 	catch(...)
 	{
-		printf("Failed to connect to daemon control socket.\n");
+		BOX_ERROR("Failed to connect to daemon control socket");
 		return false;
 	}
 
@@ -30,14 +37,14 @@
 	std::string configSummary;
 	if(!getLine.GetLine(configSummary))
 	{
-		printf("Failed to receive configuration summary from daemon\n");
+		BOX_ERROR("Failed to receive configuration summary from daemon");
 		return false;
 	}
 
 	// Was the connection rejected by the server?
 	if(getLine.IsEOF())
 	{
-		printf("Server rejected the connection.\n");
+		BOX_ERROR("Server rejected the connection");
 		return false;
 	}
 
@@ -47,7 +54,7 @@
 			&autoBackup, &updateStoreInterval, 
 			&minimumFileAge, &maxUploadWait) != 4)
 	{
-		printf("Config summary didn't decode\n");
+		BOX_ERROR("Config summary didn't decode");
 		return false;
 	}
 
@@ -81,13 +88,13 @@
 		}
 		else if (line == "error")
 		{
-			printf("ERROR (%s)\n", rCmd.c_str());
+			BOX_ERROR(rCmd);
 			break;
 		}
 		else
 		{
-			printf("WARNING: Unexpected response to command '%s': "
-				"%s", rCmd.c_str(), line.c_str());
+			BOX_WARNING("Unexpected response to command '" <<
+				rCmd << "': " << line)
 		}
 	}
 	
@@ -104,15 +111,15 @@
 	HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, false, pid);
 	if (hProcess == NULL)
 	{
-		printf("Failed to open process %d: error %d\n",
-			pid, (int)GetLastError());
+		BOX_ERROR("Failed to open process " << pid << ": " <<
+			GetErrorMessage(GetLastError()));
 		return false;
 	}
 
 	if (!TerminateProcess(hProcess, 1))
 	{
-		printf("Failed to terminate process %d: error %d\n",
-			pid, (int)GetLastError());
+		BOX_ERROR("Failed to terminate process " << pid << ": " <<
+			GetErrorMessage(GetLastError()));
 		CloseHandle(hProcess);
 		return false;
 	}




More information about the Boxbackup-commit mailing list