[SERVICES]

- Free unknown groups when their reference count reaches zero
CORE-9480 #resolve

svn path=/trunk/; revision=67059
This commit is contained in:
Thomas Faber 2015-04-05 08:58:08 +00:00
parent 77eb553987
commit 71ac07fc36
2 changed files with 19 additions and 5 deletions

View file

@ -416,8 +416,7 @@ ScmDeleteServiceRecord(PSERVICE lpService)
ScmDereferenceServiceImage(lpService->lpImage); ScmDereferenceServiceImage(lpService->lpImage);
/* Decrement the group reference counter */ /* Decrement the group reference counter */
if (lpService->lpGroup) ScmSetServiceGroup(lpService, NULL);
lpService->lpGroup->dwRefCount--;
/* FIXME: SecurityDescriptor */ /* FIXME: SecurityDescriptor */

View file

@ -32,11 +32,26 @@ ScmSetServiceGroup(PSERVICE lpService,
DPRINT("ScmSetServiceGroup(%S)\n", lpGroupName); DPRINT("ScmSetServiceGroup(%S)\n", lpGroupName);
if (lpService->lpGroup != NULL) if (lpService->lpGroup != NULL)
{
ASSERT(lpService->lpGroup->dwRefCount != 0);
ASSERT(lpService->lpGroup->dwRefCount == (DWORD)-1 ||
lpService->lpGroup->dwRefCount < 10000);
if (lpService->lpGroup->dwRefCount != (DWORD)-1)
{ {
lpService->lpGroup->dwRefCount--; lpService->lpGroup->dwRefCount--;
if (lpService->lpGroup->dwRefCount == 0)
/* FIXME: What do we have to do when dwRefCount is 0? */ {
ASSERT(lpService->lpGroup->TagCount == 0);
ASSERT(lpService->lpGroup->TagArray == NULL);
RemoveEntryList(&lpService->lpGroup->GroupListEntry);
HeapFree(GetProcessHeap(), 0, lpService->lpGroup);
lpService->lpGroup = NULL;
} }
}
}
if (lpGroupName == NULL)
return ERROR_SUCCESS;
GroupEntry = GroupListHead.Flink; GroupEntry = GroupListHead.Flink;
while (GroupEntry != &GroupListHead) while (GroupEntry != &GroupListHead)