Author: tfaber Date: Sat Sep 29 09:05:18 2012 New Revision: 57421
URL: http://svn.reactos.org/svn/reactos?rev=57421&view=rev Log: [NPFS] - Do not access ThreadContext after freeing it in NpfsWaiterThread - Correctly update Vcb->EmptyWaiterCount when terminating in NpfsWaiterThread - Fix more MSVC warnings, lots of DPRINTs
Modified: trunk/reactos/drivers/filesystems/npfs/fsctrl.c trunk/reactos/drivers/filesystems/npfs/npfs.c trunk/reactos/drivers/filesystems/npfs/rw.c
Modified: trunk/reactos/drivers/filesystems/npfs/fsctrl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/fs... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/fsctrl.c [iso-8859-1] Sat Sep 29 09:05:18 2012 @@ -361,7 +361,7 @@ /* Fail if not pipe was found */ if (Fcb == NULL) { - DPRINT("No pipe found!\n", Fcb); + DPRINT("No pipe found!\n"); return STATUS_OBJECT_NAME_NOT_FOUND; }
@@ -483,7 +483,7 @@ /* Fail if not pipe was found */ if (Fcb == NULL) { - DPRINT("No pipe found!\n", Fcb); + DPRINT("No pipe found!\n"); return STATUS_OBJECT_NAME_NOT_FOUND; }
@@ -583,7 +583,7 @@ DPRINT("OutputBufferLength: %lu\n", OutputBufferLength);
/* Validate parameters */ - if (OutputBufferLength < FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0])) + if (OutputBufferLength < (ULONG)FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0])) { DPRINT1("Buffer too small\n"); return STATUS_INVALID_PARAMETER; @@ -601,7 +601,7 @@
ExAcquireFastMutex(&Ccb->DataListLock); BufferPtr = Ccb->ReadPtr; - DPRINT("BufferPtr = %x\n", BufferPtr); + DPRINT("BufferPtr = %p\n", BufferPtr); if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) { DPRINT("Byte Stream Mode\n"); @@ -609,7 +609,7 @@ DPRINT("Reply->MessageLength %lu\n", Reply->MessageLength); MessageCount = 1;
- if (OutputBufferLength >= FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[Ccb->ReadDataAvailable])) + if (OutputBufferLength >= (ULONG)FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[Ccb->ReadDataAvailable])) { RtlCopyMemory(Reply->Data, BufferPtr, Ccb->ReadDataAvailable); ReturnLength = Ccb->ReadDataAvailable; @@ -639,7 +639,7 @@ /* If its the first message, copy the Message if the size of buffer is large enough */ if (MessageCount == 1) { - if (OutputBufferLength >= FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[MessageLength])) + if (OutputBufferLength >= (ULONG)FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[MessageLength])) { RtlCopyMemory(Reply->Data, (PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength)), @@ -649,7 +649,7 @@ }
BufferPtr = (PVOID)((ULONG_PTR)BufferPtr + sizeof(MessageLength) + MessageLength); - DPRINT("BufferPtr = %x\n", BufferPtr); + DPRINT("BufferPtr = %p\n", BufferPtr); DPRINT("ReadDataAvailable: %lu\n", ReadDataAvailable); }
Modified: trunk/reactos/drivers/filesystems/npfs/npfs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/np... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/npfs.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/npfs.c [iso-8859-1] Sat Sep 29 09:05:18 2012 @@ -67,7 +67,7 @@ &DeviceObject); if (!NT_SUCCESS(Status)) { - DPRINT("Failed to create named pipe device! (Status %x)\n", Status); + DPRINT1("Failed to create named pipe device! (Status %lx)\n", Status); return Status; }
Modified: trunk/reactos/drivers/filesystems/npfs/rw.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/rw... ============================================================================== --- trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/npfs/rw.c [iso-8859-1] Sat Sep 29 09:05:18 2012 @@ -119,7 +119,7 @@ static VOID NTAPI NpfsWaiterThread(PVOID InitContext) { - PNPFS_THREAD_CONTEXT ThreadContext = (PNPFS_THREAD_CONTEXT) InitContext; + PNPFS_THREAD_CONTEXT ThreadContext = InitContext; ULONG CurrentCount; ULONG Count = 0, i; PIRP Irp = NULL; @@ -194,9 +194,11 @@ if (ThreadContext->Count == 1 && ThreadContext->Vcb->EmptyWaiterCount >= MAXIMUM_WAIT_OBJECTS) { /* there is another thread with empty wait slots, we can remove our thread from the list */ + ASSERT(Irp == NULL); + ThreadContext->Vcb->EmptyWaiterCount -= MAXIMUM_WAIT_OBJECTS - 1; RemoveEntryList(&ThreadContext->ListEntry); + KeUnlockMutex(&ThreadContext->Vcb->PipeListLock); ExFreePoolWithTag(ThreadContext, TAG_NPFS_THREAD_CONTEXT); - KeUnlockMutex(&ThreadContext->Vcb->PipeListLock); break; } } @@ -499,7 +501,7 @@ /* If the pipe type and read mode are both byte stream */ if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) { - DPRINT("Byte stream mode: Ccb->Data %x\n", Ccb->Data); + DPRINT("Byte stream mode: Ccb->Data %p\n", Ccb->Data); /* Byte stream mode */ while (Length > 0 && Ccb->ReadDataAvailable > 0) { @@ -541,7 +543,7 @@ } else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE) { - DPRINT("Message mode: Ccb>Data %x\n", Ccb->Data); + DPRINT("Message mode: Ccb>Data %p\n", Ccb->Data);
/* Check if buffer is full and the read pointer is not at the start of the buffer */ if ((Ccb->WriteQuotaAvailable == 0) && (Ccb->ReadPtr > Ccb->Data)) @@ -611,7 +613,7 @@ Ccb->ReadPtr = Ccb->Data; } #ifndef NDEBUG - DPRINT("Length %d Buffer %x\n",CopyLength,Buffer); + DPRINT("Length %d Buffer %x\n", CopyLength, Buffer); HexDump((PUCHAR)Buffer, CopyLength); #endif
@@ -812,7 +814,7 @@
ExAcquireFastMutex(&ReaderCcb->DataListLock);
- DPRINT("Length %d Buffer %x Offset %x\n",Length,Buffer,Offset); + DPRINT("Length %lu Buffer %p Offset %lu\n", Length, Buffer, Offset);
#ifndef NDEBUG HexDump(Buffer, Length); @@ -854,7 +856,7 @@ */ if (Ccb->PipeState != FILE_PIPE_CONNECTED_STATE || !Ccb->OtherSide) { - DPRINT("PipeState: %x\n", Ccb->PipeState); + DPRINT("PipeState: %lx\n", Ccb->PipeState); Status = STATUS_PIPE_BROKEN; goto done; } @@ -869,7 +871,7 @@
if (Ccb->Fcb->PipeType == FILE_PIPE_BYTE_STREAM_TYPE) { - DPRINT("Byte stream mode: Ccb->Data %x, Ccb->WritePtr %x\n", ReaderCcb->Data, ReaderCcb->WritePtr); + DPRINT("Byte stream mode: Ccb->Data %p, Ccb->WritePtr %p\n", ReaderCcb->Data, ReaderCcb->WritePtr);
while (Length > 0 && ReaderCcb->WriteQuotaAvailable > 0) { @@ -913,7 +915,7 @@ else if (Ccb->Fcb->PipeType == FILE_PIPE_MESSAGE_TYPE) { /* For Message Type Pipe, the Pipes memory will be used to store the size of each message */ - DPRINT("Message mode: Ccb->Data %x, Ccb->WritePtr %x\n",ReaderCcb->Data, ReaderCcb->WritePtr); + DPRINT("Message mode: Ccb->Data %p, Ccb->WritePtr %p\n", ReaderCcb->Data, ReaderCcb->WritePtr); if (Length > 0) { /* Verify the WritePtr is still inside the buffer */ @@ -921,7 +923,7 @@ ((ULONG_PTR)ReaderCcb->WritePtr < (ULONG_PTR)ReaderCcb->Data)) { DPRINT1("NPFS is writing out of its buffer. Report to developer!\n"); - DPRINT1("ReaderCcb->WritePtr %x, ReaderCcb->Data %x, ReaderCcb->MaxDataLength %lu\n", + DPRINT1("ReaderCcb->WritePtr %p, ReaderCcb->Data %p, ReaderCcb->MaxDataLength %lu\n", ReaderCcb->WritePtr, ReaderCcb->Data, ReaderCcb->MaxDataLength); ASSERT(FALSE); }