atomically increment the pipe id to be thread-safe. Thanks to Mark Grosberg for repor...
authorThomas Bluemel <thomas@reactsoft.com>
Fri, 8 Oct 2004 21:48:46 +0000 (21:48 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Fri, 8 Oct 2004 21:48:46 +0000 (21:48 +0000)
svn path=/trunk/; revision=11240

reactos/lib/kernel32/file/pipe.c

index 9008fe6..a885817 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: pipe.c,v 1.10 2004/01/23 21:16:03 ekohl Exp $
+/* $Id: pipe.c,v 1.11 2004/10/08 21:48:46 weiden Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -37,15 +37,16 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
    NTSTATUS Status;
    HANDLE ReadPipeHandle;
    HANDLE WritePipeHandle;
    NTSTATUS Status;
    HANDLE ReadPipeHandle;
    HANDLE WritePipeHandle;
+   ULONG PipeId;
    PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
 
    DefaultTimeout.QuadPart = 300000000; /* 30 seconds */
 
    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,
    swprintf(Buffer,
            L"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
            NtCurrentTeb()->Cid.UniqueProcess,
-           ProcessPipeId);
+           PipeId);
    RtlInitUnicodeString (&PipeName,
                         Buffer);
 
    RtlInitUnicodeString (&PipeName,
                         Buffer);