[Box Backup-dev] COMMIT r207 - box/chris/win32/crash-test-pipes/bin/bbackupd

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Mon, 12 Dec 2005 01:13:51 +0000 (GMT)


Author: chris
Date: 2005-12-12 01:13:47 +0000 (Mon, 12 Dec 2005)
New Revision: 207

Modified:
   box/chris/win32/crash-test-pipes/bin/bbackupd/BackupDaemon.cpp
Log:
Made pipe acceptor method into a function, still crashes

Modified: box/chris/win32/crash-test-pipes/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/win32/crash-test-pipes/bin/bbackupd/BackupDaemon.cpp	2005-12-12 01:07:45 UTC (rev 206)
+++ box/chris/win32/crash-test-pipes/bin/bbackupd/BackupDaemon.cpp	2005-12-12 01:13:47 UTC (rev 207)
@@ -34,9 +34,6 @@
 
 private:
 	void Run2();
-
-	public:
-	void RunHelperThread(void);
 };
 
 #define BOX_NAMED_PIPE_NAME L"\\\\.\\pipe\\boxbackup"
@@ -82,26 +79,10 @@
 	return 0;
 }
 
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    HelperThread()
-//		Purpose: Background thread function, called by Windows,
-//			calls the BackupDaemon's RunHelperThread method
-//			to listen for and act on control communications
-//		Created: 18/2/04
-//
-// --------------------------------------------------------------------------
-unsigned int WINAPI HelperThread( LPVOID lpParam ) 
-{ 
-	printf( "Parameter = %lu.\n", *(DWORD*)lpParam ); 
-	((BackupDaemon *)lpParam)->RunHelperThread();
-
-	return 0;
-}
-
-void NamedPipeAccept(const wchar_t* pName)
+void AcceptorAcceptPipe(const wchar_t* pName)
 {
+	printf(".");
+
 	HANDLE handle;
 
 	handle = CreateNamedPipeW( 
@@ -148,13 +129,13 @@
 	}
 }
 
-void BackupDaemon::RunHelperThread(void)
-{
+unsigned int WINAPI AcceptorThread( LPVOID lpParam ) 
+{ 
 	while (true)
 	{
 		try
 		{
-			NamedPipeAccept(BOX_NAMED_PIPE_NAME);
+			AcceptorAcceptPipe(BOX_NAMED_PIPE_NAME);
 		}
 		catch (int i)
 		{
@@ -166,16 +147,10 @@
 			}
 		}
 	}
-} 
 
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    BackupDaemon::Run()
-//		Purpose: Run function for daemon
-//		Created: 18/2/04
-//
-// --------------------------------------------------------------------------
+	return 0;
+}
+
 void BackupDaemon::Run()
 {
 	// Create a thread to handle the named pipe
@@ -185,7 +160,7 @@
 	hThread = (HANDLE) _beginthreadex( 
         	NULL,                        // default security attributes 
         	0,                           // use default stack size  
-        	HelperThread,                // thread function 
+        	AcceptorThread,              // thread function 
         	this,                        // argument to thread function 
         	0,                           // use default creation flags 
         	&dwThreadId);                // returns the thread identifier