Author: ekohl
Date: Sun Feb 28 01:27:28 2010
New Revision: 45715
URL:
http://svn.reactos.org/svn/reactos?rev=45715&view=rev
Log:
[SERVICES]
- Copy service status only once after a control packet has been sent to a service.
- Send a reply packet to the service manager after a control packet has been sent to a
service.
Modified:
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/services/rpcserver.c
trunk/reactos/base/system/services/services.h
Modified: trunk/reactos/base/system/services/database.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
==============================================================================
--- trunk/reactos/base/system/services/database.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Feb 28 01:27:28 2010
@@ -679,12 +679,15 @@
DWORD
ScmControlService(PSERVICE Service,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus)
+ DWORD dwControl)
{
PSCM_CONTROL_PACKET ControlPacket;
- DWORD Count;
+ SCM_REPLY_PACKET ReplyPacket;
+
+ DWORD dwWriteCount = 0;
+ DWORD dwReadCount = 0;
DWORD TotalLength;
+ DWORD dwError = ERROR_SUCCESS;
DPRINT("ScmControlService() called\n");
@@ -705,23 +708,29 @@
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength * sizeof(WCHAR)),
- &Count,
+ &dwWriteCount,
NULL);
- /* FIXME: Read the reply */
+ /* Read the reply */
+ ReadFile(Service->ControlPipeHandle,
+ &ReplyPacket,
+ sizeof(SCM_REPLY_PACKET),
+ &dwReadCount,
+ NULL);
/* Release the contol packet */
HeapFree(GetProcessHeap(),
0,
ControlPacket);
- RtlCopyMemory(lpServiceStatus,
- &Service->Status,
- sizeof(SERVICE_STATUS));
-
- DPRINT("ScmControlService) done\n");
-
- return ERROR_SUCCESS;
+ if (dwReadCount == sizeof(SCM_REPLY_PACKET))
+ {
+ dwError = ReplyPacket.dwError;
+ }
+
+ DPRINT("ScmControlService() done\n");
+
+ return dwError;
}
@@ -731,11 +740,15 @@
LPWSTR *argv)
{
PSCM_CONTROL_PACKET ControlPacket;
+ SCM_REPLY_PACKET ReplyPacket;
DWORD TotalLength;
DWORD ArgsLength = 0;
DWORD Length;
PWSTR Ptr;
- DWORD Count;
+ DWORD dwWriteCount = 0;
+ DWORD dwReadCount = 0;
+ DWORD dwError = ERROR_SUCCESS;
+ DWORD i;
DPRINT("ScmSendStartCommand() called\n");
@@ -743,10 +756,10 @@
TotalLength = wcslen(Service->lpServiceName) + 1;
if (argc > 0)
{
- for (Count = 0; Count < argc; Count++)
- {
- DPRINT("Arg: %S\n", argv[Count]);
- Length = wcslen(argv[Count]) + 1;
+ for (i = 0; i < argc; i++)
+ {
+ DPRINT("Arg: %S\n", argv[i]);
+ Length = wcslen(argv[i]) + 1;
TotalLength += Length;
ArgsLength += Length;
}
@@ -786,19 +799,29 @@
WriteFile(Service->ControlPipeHandle,
ControlPacket,
sizeof(SCM_CONTROL_PACKET) + (TotalLength - 1) * sizeof(WCHAR),
- &Count,
+ &dwWriteCount,
NULL);
- /* FIXME: Read the reply */
+ /* Read the reply */
+ ReadFile(Service->ControlPipeHandle,
+ &ReplyPacket,
+ sizeof(SCM_REPLY_PACKET),
+ &dwReadCount,
+ NULL);
/* Release the contol packet */
HeapFree(GetProcessHeap(),
0,
ControlPacket);
+ if (dwReadCount == sizeof(SCM_REPLY_PACKET))
+ {
+ dwError = ReplyPacket.dwError;
+ }
+
DPRINT("ScmSendStartCommand() done\n");
- return ERROR_SUCCESS;
+ return dwError;
}
@@ -1192,7 +1215,6 @@
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
- SERVICE_STATUS ServiceStatus;
DPRINT("ScmAutoShutdownServices() called\n");
@@ -1205,7 +1227,7 @@
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
{
/* shutdown service */
- ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus);
+ ScmControlService(CurrentService, SERVICE_CONTROL_STOP);
}
ServiceEntry = ServiceEntry->Flink;
Modified: trunk/reactos/base/system/services/rpcserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Feb 28 01:27:28 2010
@@ -637,8 +637,12 @@
{
/* Send control code to the service */
dwError = ScmControlService(lpService,
- dwControl,
- lpServiceStatus);
+ dwControl);
+
+ /* Return service status information */
+ RtlCopyMemory(lpServiceStatus,
+ &lpService->Status,
+ sizeof(SERVICE_STATUS));
}
if ((dwError == ERROR_SUCCESS) && (pcbBytesNeeded))
@@ -652,10 +656,6 @@
lpService->ThreadId = 0;
}
- /* Return service status information */
- RtlCopyMemory(lpServiceStatus,
- &lpService->Status,
- sizeof(SERVICE_STATUS));
return dwError;
}
Modified: trunk/reactos/base/system/services/services.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.h [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/services.h [iso-8859-1] Sun Feb 28 01:27:28 2010
@@ -117,8 +117,7 @@
DWORD ScmMarkServiceForDelete(PSERVICE pService);
DWORD ScmControlService(PSERVICE Service,
- DWORD dwControl,
- LPSERVICE_STATUS lpServiceStatus);
+ DWORD dwControl);
BOOL ScmLockDatabaseExclusive(VOID);
BOOL ScmLockDatabaseShared(VOID);