Author: cgutman Date: Tue Sep 21 06:40:41 2010 New Revision: 48841
URL: http://svn.reactos.org/svn/reactos?rev=48841&view=rev Log: [LWIP] - Don't call KeSetEvent while holding a spin lock (thanks to lassy for pointing it out) - Don't advance to the next list entry because we are using ExInterlockedRemoveHeadList - A couple more small code improvements
Modified: branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c
Modified: branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c URL: http://svn.reactos.org/svn/reactos/branches/tcp-rewrite-branch/lib/drivers/l... ============================================================================== --- branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] (original) +++ branches/tcp-rewrite-branch/lib/drivers/lwip/src/sys_arch.c [iso-8859-1] Tue Sep 21 06:40:41 2010 @@ -58,11 +58,13 @@ sys_sem_t sys_sem_new(u8_t count) { - sys_sem_t sem = ExAllocatePool(NonPagedPool, sizeof(KEVENT)); + sys_sem_t sem; + + ASSERT(count == 0 || count == 1); + + sem = ExAllocatePool(NonPagedPool, sizeof(KEVENT)); if (!sem) return SYS_SEM_NULL; - - ASSERT(count == 0 || count == 1);
/* It seems lwIP uses the semaphore implementation as either a completion event or a lock * so I optimize for this case by using a synchronization event and setting its initial state @@ -155,19 +157,17 @@ sys_mbox_post(sys_mbox_t mbox, void *msg) { PLWIP_MESSAGE_CONTAINER Container; - KIRQL OldIrql;
Container = ExAllocatePool(NonPagedPool, sizeof(*Container)); ASSERT(Container);
Container->Message = msg;
- KeAcquireSpinLock(&mbox->Lock, &OldIrql); - InsertTailList(&mbox->ListHead, - &Container->ListEntry); + ExInterlockedInsertTailList(&mbox->ListHead, + &Container->ListEntry, + &mbox->Lock);
KeSetEvent(&mbox->Event, IO_NO_INCREMENT, FALSE); - KeReleaseSpinLock(&mbox->Lock, OldIrql); }
u32_t @@ -201,13 +201,13 @@ ASSERT(Entry); if (IsListEmpty(&mbox->ListHead)) KeClearEvent(&mbox->Event); - Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry); KeReleaseSpinLock(&mbox->Lock, OldIrql);
KeQuerySystemTime(&PostWaitTime); TimeDiff = PostWaitTime.QuadPart - PreWaitTime.QuadPart; TimeDiff /= 10000;
+ Container = CONTAINING_RECORD(Entry, LWIP_MESSAGE_CONTAINER, ListEntry); Message = Container->Message; ExFreePool(Container);
@@ -374,7 +374,5 @@
ZwClose(Container->Handle); } - - CurrentEntry = CurrentEntry->Flink; - } -} + } +}