[ros-diffs] [cgutman] 47642: [NDIS] - Hold the miniport lock when we work with the timer queue - Use the return value of KeSetTimer(Ex) to determine whether we need to queue the timer in our queue, otherwise we just use the entry that is already there - Add more assertions
cgutman at svn.reactos.org
cgutman at svn.reactos.org
Mon Jun 7 00:08:41 CEST 2010
- Previous message: [ros-diffs] [tkreuzer] 47641: [WIN32K] Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
- Next message: [ros-diffs] [cgutman] 47643: [MSAFD] - Fix many times where we wait for an operation but don't update our status and return if it failed - Fix the overlapped pending case in writing which was completely broken (callers would detect an error but GetLastError would return 0 because we didn't store the error in the lpErrno variable) - Fix many times where we pass a pointer to an event that we close without waiting - Fix a bug in WSPEnumNetworkEvents when we would set WSAEINVAL in the lpErrno variable but not return SOCKET_ERROR so the error got ignored
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: cgutman
Date: Mon Jun 7 00:08:40 2010
New Revision: 47642
URL: http://svn.reactos.org/svn/reactos?rev=47642&view=rev
Log:
[NDIS]
- Hold the miniport lock when we work with the timer queue
- Use the return value of KeSetTimer(Ex) to determine whether we need to queue the timer in our queue, otherwise we just use the entry that is already there
- Add more assertions
Modified:
trunk/reactos/drivers/network/ndis/ndis/time.c
Modified: trunk/reactos/drivers/network/ndis/ndis/time.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/time.c?rev=47642&r1=47641&r2=47642&view=diff
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/time.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/time.c [iso-8859-1] Mon Jun 7 00:08:40 2010
@@ -98,6 +98,8 @@
BOOLEAN DequeueMiniportTimer(PNDIS_MINIPORT_TIMER Timer)
{
PNDIS_MINIPORT_TIMER CurrentTimer;
+
+ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
if (!Timer->Miniport->TimerQueue)
return FALSE;
@@ -143,13 +145,21 @@
* - call at IRQL <= DISPATCH_LEVEL
*/
{
+ KIRQL OldIrql;
+
ASSERT_IRQL(DISPATCH_LEVEL);
ASSERT(TimerCancelled);
ASSERT(Timer);
*TimerCancelled = KeCancelTimer (&Timer->Timer);
- DequeueMiniportTimer(Timer);
+ if (*TimerCancelled)
+ {
+ KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
+ /* If it's somebody already dequeued it, something is wrong (maybe a double-cancel?) */
+ if (!DequeueMiniportTimer(Timer)) ASSERT(FALSE);
+ KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
+ }
}
VOID NTAPI
@@ -166,7 +176,13 @@
SystemArgument2);
/* Only dequeue if the timer has a period of 0 */
- if (!Timer->Timer.Period) DequeueMiniportTimer(Timer);
+ if (!Timer->Timer.Period)
+ {
+ KeAcquireSpinLockAtDpcLevel(&Timer->Miniport->Lock);
+ /* If someone already dequeued it, something is wrong (borked timer implementation?) */
+ if (!DequeueMiniportTimer(Timer)) ASSERT(FALSE);
+ KeReleaseSpinLockFromDpcLevel(&Timer->Miniport->Lock);
+ }
}
@@ -224,6 +240,7 @@
*/
{
LARGE_INTEGER Timeout;
+ KIRQL OldIrql;
ASSERT_IRQL(DISPATCH_LEVEL);
ASSERT(Timer);
@@ -231,14 +248,15 @@
/* relative delays are negative, absolute are positive; resolution is 100ns */
Timeout.QuadPart = Int32x32To64(MillisecondsPeriod, -10000);
- /* Dequeue the timer if it is queued already */
- DequeueMiniportTimer(Timer);
-
- /* Add the timer at the head of the timer queue */
- Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
- Timer->Miniport->TimerQueue = Timer;
-
- KeSetTimerEx (&Timer->Timer, Timeout, MillisecondsPeriod, &Timer->Dpc);
+ KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
+ /* If KeSetTimer(Ex) returns FALSE then the timer is not in the system's queue (and not in ours either) */
+ if (!KeSetTimerEx(&Timer->Timer, Timeout, MillisecondsPeriod, &Timer->Dpc))
+ {
+ /* Add the timer at the head of the timer queue */
+ Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
+ Timer->Miniport->TimerQueue = Timer;
+ }
+ KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
}
@@ -262,6 +280,7 @@
*/
{
LARGE_INTEGER Timeout;
+ KIRQL OldIrql;
ASSERT_IRQL(DISPATCH_LEVEL);
ASSERT(Timer);
@@ -269,14 +288,15 @@
/* relative delays are negative, absolute are positive; resolution is 100ns */
Timeout.QuadPart = Int32x32To64(MillisecondsToDelay, -10000);
- /* Dequeue the timer if it is queued already */
- DequeueMiniportTimer(Timer);
-
- /* Add the timer at the head of the timer queue */
- Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
- Timer->Miniport->TimerQueue = Timer;
-
- KeSetTimer (&Timer->Timer, Timeout, &Timer->Dpc);
+ KeAcquireSpinLock(&Timer->Miniport->Lock, &OldIrql);
+ /* If KeSetTimer(Ex) returns FALSE then the timer is not in the system's queue (and not in ours either) */
+ if (!KeSetTimer(&Timer->Timer, Timeout, &Timer->Dpc))
+ {
+ /* Add the timer at the head of the timer queue */
+ Timer->NextDeferredTimer = Timer->Miniport->TimerQueue;
+ Timer->Miniport->TimerQueue = Timer;
+ }
+ KeReleaseSpinLock(&Timer->Miniport->Lock, OldIrql);
}
- Previous message: [ros-diffs] [tkreuzer] 47641: [WIN32K] Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
- Next message: [ros-diffs] [cgutman] 47643: [MSAFD] - Fix many times where we wait for an operation but don't update our status and return if it failed - Fix the overlapped pending case in writing which was completely broken (callers would detect an error but GetLastError would return 0 because we didn't store the error in the lpErrno variable) - Fix many times where we pass a pointer to an event that we close without waiting - Fix a bug in WSPEnumNetworkEvents when we would set WSAEINVAL in the lpErrno variable but not return SOCKET_ERROR so the error got ignored
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Ros-diffs
mailing list