Author: dgorbachev
Date: Mon Feb 22 22:36:07 2010
New Revision: 45661
URL:
http://svn.reactos.org/svn/reactos?rev=45661&view=rev
Log:
Clean up RPCSS.
Modified:
trunk/reactos/base/services/rpcss/rpcss_main.c
trunk/reactos/base/services/rpcss/rpcss_ros.diff
trunk/reactos/base/services/rpcss/service_main.c
Modified: trunk/reactos/base/services/rpcss/rpcss_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/rpcss/rpcss_…
==============================================================================
--- trunk/reactos/base/services/rpcss/rpcss_main.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/rpcss/rpcss_main.c [iso-8859-1] Mon Feb 22 22:36:07 2010
@@ -58,7 +58,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
-static HANDLE exit_event;
+HANDLE exit_event;
//extern HANDLE __wine_make_process_system(void);
Modified: trunk/reactos/base/services/rpcss/rpcss_ros.diff
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/rpcss/rpcss_…
==============================================================================
--- trunk/reactos/base/services/rpcss/rpcss_ros.diff [iso-8859-1] (original)
+++ trunk/reactos/base/services/rpcss/rpcss_ros.diff [iso-8859-1] Mon Feb 22 22:36:07
2010
@@ -1,8 +1,13 @@
Index: rpcss_main.c
===================================================================
---- rpcss_main.c (revision 37240)
-+++ rpcss_main.c (working copy)
-@@ -62,7 +62,7 @@
+--- rpcss_main.c
++++ rpcss_main.c
+@@ -58,11 +58,11 @@
+
+ WINE_DEFAULT_DEBUG_CHANNEL(ole);
+
+-static HANDLE exit_event;
++HANDLE exit_event;
//extern HANDLE __wine_make_process_system(void);
Modified: trunk/reactos/base/services/rpcss/service_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/rpcss/servic…
==============================================================================
--- trunk/reactos/base/services/rpcss/service_main.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/rpcss/service_main.c [iso-8859-1] Mon Feb 22 22:36:07
2010
@@ -9,120 +9,90 @@
#include "rpcss.h"
-BOOL RPCSS_Initialize(void);
-BOOL RPCSS_Shutdown(void);
+#define NDEBUG
+#include <debug.h>
+extern BOOL RPCSS_Initialize(void);
+extern BOOL RPCSS_Shutdown(void);
+extern HANDLE exit_event;
+
+static VOID WINAPI ServiceMain(DWORD, LPWSTR *);
static WCHAR ServiceName[] = L"RpcSs";
+SERVICE_TABLE_ENTRYW ServiceTable[] =
+{
+ { ServiceName, ServiceMain },
+ { NULL, NULL }
+};
-typedef struct _ServiceInfo
+static SERVICE_STATUS ServiceStatus;
+static SERVICE_STATUS_HANDLE ServiceStatusHandle;
+
+DWORD WINAPI
+ServiceControlHandler(DWORD dwControl,
+ DWORD dwEventType,
+ LPVOID lpEventData,
+ LPVOID lpContext)
{
- SERVICE_STATUS servStatus;
- SERVICE_STATUS_HANDLE hStatus;
-} SERVICEINFO, *PSERVICEINFO;
-
-
-static VOID
-UpdateStatus(PSERVICEINFO pServInfo,
- DWORD NewStatus,
- DWORD Check)
-{
- if (Check > 0)
- {
- pServInfo->servStatus.dwCheckPoint += Check;
- }
- else
- {
- pServInfo->servStatus.dwCheckPoint = Check;
- }
-
- if (NewStatus > 0)
- {
- pServInfo->servStatus.dwCurrentState = NewStatus;
- }
-
- SetServiceStatus(pServInfo->hStatus, &pServInfo->servStatus);
-}
-
-
-static BOOL
-RunService(PSERVICEINFO pServInfo)
-{
- return RPCSS_Initialize();
-}
-
-VOID WINAPI
-ServerCtrlHandler(DWORD dwControl,
- DWORD dwEventType,
- LPVOID lpEventData,
- LPVOID lpContext)
-{
- PSERVICEINFO pServInfo = (PSERVICEINFO)lpContext;
-
switch (dwControl)
{
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
- RPCSS_Shutdown();
- pServInfo->servStatus.dwWin32ExitCode = 0;
- pServInfo->servStatus.dwWaitHint = 0;
- UpdateStatus(pServInfo, SERVICE_STOP_PENDING, 1);
- break;
+ SetEvent(exit_event);
+ return NO_ERROR;
+
+ case SERVICE_CONTROL_INTERROGATE:
+ return NO_ERROR;
default:
- break;
+ return ERROR_CALL_NOT_IMPLEMENTED;
}
}
VOID WINAPI
ServiceMain(DWORD argc, LPWSTR argv[])
{
- SERVICEINFO servInfo;
- HANDLE hThread;
- DWORD dwThreadId;
+ DWORD dwError;
- servInfo.servStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
- servInfo.servStatus.dwCurrentState = SERVICE_STOPPED;
- servInfo.servStatus.dwControlsAccepted = SERVICE_ACCEPT_SHUTDOWN;
- servInfo.servStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
- servInfo.servStatus.dwServiceSpecificExitCode = 0;
- servInfo.servStatus.dwCheckPoint = 0;
- servInfo.servStatus.dwWaitHint = 1000;
+ ServiceStatusHandle = RegisterServiceCtrlHandlerExW(ServiceName,
+ ServiceControlHandler,
+ NULL);
+ if (!ServiceStatusHandle)
+ {
+ dwError = GetLastError();
+ DPRINT1("RegisterServiceCtrlHandlerW() failed! (Error %lu)\n",
dwError);
+ return;
+ }
- servInfo.hStatus = RegisterServiceCtrlHandlerExW(ServiceName,
-
(LPHANDLER_FUNCTION_EX)ServerCtrlHandler,
- &servInfo);
- if (!servInfo.hStatus) return;
+ ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
+ ServiceStatus.dwControlsAccepted = 0;
+ ServiceStatus.dwWin32ExitCode = NO_ERROR;
+ ServiceStatus.dwServiceSpecificExitCode = 0;
+ ServiceStatus.dwCheckPoint = 0;
+ ServiceStatus.dwWaitHint = 1000;
+ SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
- UpdateStatus(&servInfo, SERVICE_START_PENDING, 1);
+ if (RPCSS_Initialize())
+ {
+ ServiceStatus.dwCurrentState = SERVICE_RUNNING;
+ ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP |
SERVICE_ACCEPT_SHUTDOWN;
+ SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
- /* Create worker thread */
- hThread = CreateThread(NULL,
- 0,
- (LPTHREAD_START_ROUTINE)RunService,
- &servInfo,
- 0,
- &dwThreadId);
- if (!hThread) return;
+ WaitForSingleObject(exit_event, INFINITE);
- /* Set service status to running */
- UpdateStatus(&servInfo, SERVICE_RUNNING, 0);
-
- /* Wait until thread has terminated */
- WaitForSingleObject(hThread, INFINITE);
-
- CloseHandle(hThread);
-
- UpdateStatus(&servInfo, SERVICE_STOPPED, 0);
+ ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+ SetServiceStatus(ServiceStatusHandle, &ServiceStatus);
+ RPCSS_Shutdown();
+ }
}
+int wmain(int argc, LPWSTR argv[])
+{
+ if (!StartServiceCtrlDispatcherW(ServiceTable))
+ {
+ DPRINT1("StartServiceCtrlDispatcherW() failed\n");
+ return 1;
+ }
-int wmain(int argc, LPWSTR argv [])
-{
- SERVICE_TABLE_ENTRYW ServiceTable[] =
- {
- {ServiceName, ServiceMain},
- {NULL, NULL }
- };
-
- return (int)(StartServiceCtrlDispatcherW(ServiceTable) != TRUE);
+ return 0;
}