Revert 18883 and 18912, as they break named pipes
[reactos.git] / reactos / lib / kernel32 / file / pipe.c
index 9008fe6..f5e65d5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pipe.c,v 1.10 2004/01/23 21:16:03 ekohl Exp $
+/* $Id$
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -37,35 +37,33 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
    NTSTATUS Status;
    HANDLE ReadPipeHandle;
    HANDLE WritePipeHandle;
+   ULONG PipeId;
+   ULONG Attributes;
    PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
 
    DefaultTimeout.QuadPart = 300000000; /* 30 seconds */
 
-   ProcessPipeId++;
+   PipeId = (ULONG)InterlockedIncrement((LONG*)&ProcessPipeId);
    swprintf(Buffer,
            L"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
            NtCurrentTeb()->Cid.UniqueProcess,
-           ProcessPipeId);
+           PipeId);
    RtlInitUnicodeString (&PipeName,
                         Buffer);
 
+   Attributes = OBJ_CASE_INSENSITIVE;
    if (lpPipeAttributes)
      {
        SecurityDescriptor = lpPipeAttributes->lpSecurityDescriptor;
+       if (lpPipeAttributes->bInheritHandle)
+         Attributes |= OBJ_INHERIT;
      }
 
    InitializeObjectAttributes(&ObjectAttributes,
                              &PipeName,
-                             OBJ_CASE_INSENSITIVE,
+                             Attributes,
                              NULL,
                              SecurityDescriptor);
-   if (lpPipeAttributes)
-   {
-      if(lpPipeAttributes->bInheritHandle)
-         ObjectAttributes.Attributes |= OBJ_INHERIT;
-      if (lpPipeAttributes->lpSecurityDescriptor)
-        ObjectAttributes.SecurityDescriptor = lpPipeAttributes->lpSecurityDescriptor;
-   }
 
    Status = NtCreateNamedPipeFile(&ReadPipeHandle,
                                  FILE_GENERIC_READ,
@@ -91,7 +89,7 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
                       FILE_GENERIC_WRITE,
                       &ObjectAttributes,
                       &StatusBlock,
-                      FILE_SHARE_READ | FILE_SHARE_WRITE,
+                      0,
                       FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
    if (!NT_SUCCESS(Status))
      {