- Unbreak build
authorAlex Ionescu <aionescu@gmail.com>
Wed, 9 Nov 2005 03:02:33 +0000 (03:02 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Wed, 9 Nov 2005 03:02:33 +0000 (03:02 +0000)
- Fix CallNamedPipeW, the pipe mode should also be set to PIPE_WAIT.

svn path=/trunk/; revision=19086

reactos/lib/kernel32/file/npipe.c

index 91d6546..7048002 100644 (file)
@@ -674,12 +674,12 @@ CallNamedPipeA(LPCSTR lpNamedPipeName,
                LPDWORD lpBytesRead,
                DWORD nTimeOut)
 {
                LPDWORD lpBytesRead,
                DWORD nTimeOut)
 {
-    UNICODE_STRING PipeName = &NtCurrentTeb()->StaticUnicodeString;
+    PUNICODE_STRING PipeName = &NtCurrentTeb()->StaticUnicodeString;
     ANSI_STRING AnsiPipe;
 
     /* Initialize the string as ANSI_STRING and convert to Unicode */
     ANSI_STRING AnsiPipe;
 
     /* Initialize the string as ANSI_STRING and convert to Unicode */
-    RtlInitAnsiString(&NameA, (LPSTR)lpName);
-    RtlAnsiStringToUnicodeString(NameU, &NameA, FALSE);
+    RtlInitAnsiString(&AnsiPipe, (LPSTR)lpNamedPipeName);
+    RtlAnsiStringToUnicodeString(PipeName, &AnsiPipe, FALSE);
 
     /* Call the Unicode function */
     return CallNamedPipeW(PipeName->Buffer,
 
     /* Call the Unicode function */
     return CallNamedPipeW(PipeName->Buffer,
@@ -694,65 +694,69 @@ CallNamedPipeA(LPCSTR lpNamedPipeName,
 /*
  * @implemented
  */
 /*
  * @implemented
  */
-BOOL STDCALL
+BOOL
+WINAPI
 CallNamedPipeW(LPCWSTR lpNamedPipeName,
 CallNamedPipeW(LPCWSTR lpNamedPipeName,
-              LPVOID lpInBuffer,
-              DWORD nInBufferSize,
-              LPVOID lpOutBuffer,
-              DWORD nOutBufferSize,
-              LPDWORD lpBytesRead,
-              DWORD nTimeOut)
+               LPVOID lpInBuffer,
+               DWORD nInBufferSize,
+               LPVOID lpOutBuffer,
+               DWORD nOutBufferSize,
+               LPDWORD lpBytesRead,
+               DWORD nTimeOut)
 {
 {
-  HANDLE hPipe = INVALID_HANDLE_VALUE;
-  BOOL bRetry = TRUE;
-  BOOL bError = FALSE;
-  DWORD dwPipeMode;
+    HANDLE hPipe;
+    BOOL bRetry = TRUE;
+    BOOL bError;
+    DWORD dwPipeMode;
 
 
-  while (TRUE)
+    while (TRUE)
     {
     {
-      hPipe = CreateFileW(lpNamedPipeName,
-                         GENERIC_READ | GENERIC_WRITE,
-                         FILE_SHARE_READ | FILE_SHARE_WRITE,
-                         NULL,
-                         OPEN_EXISTING,
-                         FILE_ATTRIBUTE_NORMAL,
-                         NULL);
-      if (hPipe != INVALID_HANDLE_VALUE)
-       break;
-
-      if (bRetry == FALSE)
-       return(FALSE);
-
-      WaitNamedPipeW(lpNamedPipeName,
-                    nTimeOut);
-
-      bRetry = FALSE;
+        /* Try creating it */
+        hPipe = CreateFileW(lpNamedPipeName,
+                            GENERIC_READ | GENERIC_WRITE,
+                            FILE_SHARE_READ | FILE_SHARE_WRITE,
+                            NULL,
+                            OPEN_EXISTING,
+                            FILE_ATTRIBUTE_NORMAL,
+                            NULL);
+
+        /* Success, break out */
+        if (hPipe != INVALID_HANDLE_VALUE) break;
+
+        /* Already tried twice, give up */
+        if (bRetry == FALSE) return FALSE;
+
+        /* Wait on it */
+        WaitNamedPipeW(lpNamedPipeName, nTimeOut);
+
+        /* Get ready to try again */
+        bRetry = FALSE;
     }
 
     }
 
-  dwPipeMode = PIPE_READMODE_MESSAGE;
-  bError = SetNamedPipeHandleState(hPipe,
-                                  &dwPipeMode,
-                                  NULL,
-                                  NULL);
-  if (!bError)
+    /* Set the pipe mode */
+    dwPipeMode = PIPE_READMODE_MESSAGE | PIPE_WAIT;
+    bError = SetNamedPipeHandleState(hPipe, &dwPipeMode, NULL, NULL);
+    if (!bError)
     {
     {
-      CloseHandle(hPipe);
-      return(FALSE);
+        /* Couldn't change state, fail */
+        CloseHandle(hPipe);
+        return FALSE;
     }
 
     }
 
-  bError = TransactNamedPipe(hPipe,
-                            lpInBuffer,
-                            nInBufferSize,
-                            lpOutBuffer,
-                            nOutBufferSize,
-                            lpBytesRead,
-                            NULL);
-  CloseHandle(hPipe);
-
-  return(bError);
+    /* Do the transact */
+    bError = TransactNamedPipe(hPipe,
+                               lpInBuffer,
+                               nInBufferSize,
+                               lpOutBuffer,
+                               nOutBufferSize,
+                               lpBytesRead,
+                               NULL);
+    
+    /* Close the handle and return */
+    CloseHandle(hPipe);
+    return bError;
 }
 
 }
 
-
 /*
  * @implemented
  */
 /*
  * @implemented
  */