Commit in reactos/drivers/fs/np on MAIN
create.c+22-91.26 -> 1.27
fsctrl.c+18-31.17 -> 1.18
+40-12
2 modified files
Use a new passive pipe state (0) to ensure that client ends don't connect to server ends in calls to WaitNamed Pipe().

reactos/drivers/fs/np
create.c 1.26 -> 1.27
diff -u -r1.26 -r1.27
--- create.c	23 Dec 2004 23:58:44 -0000	1.26
+++ create.c	30 Dec 2004 12:34:26 -0000	1.27
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.26 2004/12/23 23:58:44 ekohl Exp $
+/* $Id: create.c,v 1.27 2004/12/30 12:34:26 ekohl Exp $
  *
  * COPYRIGHT:  See COPYING in the top level directory
  * PROJECT:    ReactOS kernel
@@ -74,7 +74,7 @@
   PFILE_OBJECT FileObject;
   PNPFS_PIPE Pipe;
   PNPFS_FCB ClientFcb;
-  PNPFS_FCB ServerFcb;
+  PNPFS_FCB ServerFcb = NULL;
   PNPFS_DEVICE_EXTENSION DeviceExt;
   ULONG Disposition;
 
@@ -89,6 +89,11 @@
 
   Irp->IoStatus.Information = 0;
 
+  if (Disposition & FILE_OPEN)
+    {
+      DPRINT("NpfsCreate() open client end for special use!\n");
+    }
+
   /*
    * Step 1. Find the pipe we're trying to open.
    */
@@ -117,19 +122,27 @@
    */
   KeLockMutex(&Pipe->FcbListLock);
 
-  ServerFcb = NpfsFindListeningServerInstance(Pipe);
-  if (ServerFcb == NULL)
+  if (!(Disposition & FILE_OPEN))
     {
-      /* Not found, bail out with error for FILE_OPEN requests. */
-      DPRINT("No server fcb found!\n");
-      if (Disposition == FILE_OPEN)
+      ServerFcb = NpfsFindListeningServerInstance(Pipe);
+      if (ServerFcb == NULL)
         {
+          /* Not found, bail out with error for FILE_OPEN requests. */
+          DPRINT("No listening server fcb found!\n");
           KeUnlockMutex(&Pipe->FcbListLock);
           Irp->IoStatus.Status = STATUS_PIPE_BUSY;
           IoCompleteRequest(Irp, IO_NO_INCREMENT);
           return STATUS_PIPE_BUSY;
         }
     }
+  else if (IsListEmpty(&Pipe->ServerFcbListHead))
+    {
+      DPRINT("No server fcb found!\n");
+      KeUnlockMutex(&Pipe->FcbListLock);
+      Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
+      IoCompleteRequest(Irp, IO_NO_INCREMENT);
+      return STATUS_UNSUCCESSFUL;
+    }
 
   /*
    * Step 3. Create the client FCB.
@@ -147,7 +160,7 @@
   ClientFcb->Pipe = Pipe;
   ClientFcb->PipeEnd = FILE_PIPE_CLIENT_END;
   ClientFcb->OtherSide = NULL;
-  ClientFcb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
+  ClientFcb->PipeState = (Disposition & FILE_OPEN) ? 0 : FILE_PIPE_DISCONNECTED_STATE;
 
   /* Initialize data list. */
   if (Pipe->InboundQuota)
@@ -480,7 +493,7 @@
 #endif
          /*
           * Signaling the write event. If is possible that an other
-          * thread waits of an empty buffer.
+          * thread waits for an empty buffer.
           */
          KeSetEvent(&Fcb->OtherSide->Event, IO_NO_INCREMENT, FALSE);
       }

reactos/drivers/fs/np
fsctrl.c 1.17 -> 1.18
diff -u -r1.17 -r1.18
--- fsctrl.c	23 Dec 2004 12:38:16 -0000	1.17
+++ fsctrl.c	30 Dec 2004 12:34:27 -0000	1.18
@@ -1,4 +1,4 @@
-/* $Id: fsctrl.c,v 1.17 2004/12/23 12:38:16 ekohl Exp $
+/* $Id: fsctrl.c,v 1.18 2004/12/30 12:34:27 ekohl Exp $
  *
  * COPYRIGHT:  See COPYING in the top level directory
  * PROJECT:    ReactOS kernel
@@ -51,6 +51,16 @@
 				    NPFS_FCB,
 				    FcbListEntry);
 
+      if (ClientFcb->PipeState == 0)
+	{
+	  /* found a passive (waiting) client fcb */
+	  DPRINT("Passive (waiting) client fcb found -- wake the client\n");
+	  KeSetEvent(&ClientFcb->ConnectEvent, IO_NO_INCREMENT, FALSE);
+	  break;
+	}
+
+
+#if 0
       if (ClientFcb->PipeState == FILE_PIPE_LISTENING_STATE)
 	{
 	  /* found a listening client fcb */
@@ -74,6 +84,7 @@
 
 	  return STATUS_PIPE_CONNECTED;
 	}
+#endif
 
       current_entry = current_entry->Flink;
     }
@@ -157,6 +168,12 @@
   WaitPipe = (PNPFS_WAIT_PIPE)Irp->AssociatedIrp.SystemBuffer;
   Pipe = Fcb->Pipe;
 
+  if (Fcb->PipeState != 0)
+    {
+      DPRINT("Pipe is not in passive (waiting) state!\n");
+      return STATUS_UNSUCCESSFUL;
+    }
+
   /* search for listening server */
   current_entry = Pipe->ServerFcbListHead.Flink;
   while (current_entry != &Pipe->ServerFcbListHead)
@@ -177,8 +194,6 @@
     }
 
   /* no listening server fcb found -- wait for one */
-  Fcb->PipeState = FILE_PIPE_LISTENING_STATE;
-
   Status = KeWaitForSingleObject(&Fcb->ConnectEvent,
 				 UserRequest,
 				 KernelMode,
CVSspam 0.2.8