From 2522eb7b9b02ff38af09366e141a3cac54816d84 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 15 Jan 2010 21:00:50 +0000 Subject: [PATCH] - Fix a bug with our tei_instance selection (we could end up with the same tei_instance value on different entities of the same type if an entity of our type in the middle of the list was deleted previously) svn path=/branches/aicom-network-branch/; revision=45090 --- drivers/network/tcpip/tcpip/info.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/network/tcpip/tcpip/info.c b/drivers/network/tcpip/tcpip/info.c index 2eaae32a884..4e11d9aa122 100644 --- a/drivers/network/tcpip/tcpip/info.c +++ b/drivers/network/tcpip/tcpip/info.c @@ -15,16 +15,27 @@ VOID AddEntity(ULONG EntityType, PVOID Context, ULONG Flags) { KIRQL OldIrql; - ULONG i, Count = 0; + ULONG i, Instance = 0; + BOOLEAN ChoseIndex = FALSE; TcpipAcquireSpinLock(&EntityListLock, &OldIrql); - for (i = 0; i < EntityCount; i++) - if (EntityList[i].tei_entity == EntityType) - Count++; + while (!ChoseIndex) + { + ChoseIndex = TRUE; + for (i = 0; i < EntityCount; i++) + { + if (EntityList[i].tei_entity == EntityType && + EntityList[i].tei_instance == Instance) + { + Instance++; + ChoseIndex = FALSE; + } + } + } EntityList[EntityCount].tei_entity = EntityType; - EntityList[EntityCount].tei_instance = Count; + EntityList[EntityCount].tei_instance = Instance; EntityList[EntityCount].context = Context; EntityList[EntityCount].flags = Flags; EntityCount++; -- 2.17.1