ntdll/kernel32: #26

Eric Pouech pouech-eric at wanadoo.fr
Mon May 19 15:31:09 CDT 2003


now that we have a more decent named pipe implementation, we can get rid 
of anonymous pipes and implement them as NT does: on top of named pipes

of course, run tools/make_requests and remove scheduler/pipe.c and 
server/pipe.c

A+
-- 
Eric Pouech
-------------- next part --------------
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/kernel25/sync.c dlls/kernel/sync.c
--- dlls/kernel25/sync.c	2003-05-15 20:33:40.000000000 +0200
+++ dlls/kernel/sync.c	2003-05-19 22:20:06.000000000 +0200
@@ -32,6 +32,7 @@
 #ifdef HAVE_SYS_POLL_H
 #include <sys/poll.h>
 #endif
+#include <stdio.h>
 
 #include "winbase.h"
 #include "winerror.h"
@@ -873,3 +874,39 @@
            lpOutput, lpOutputSize, lpBytesRead, nTimeout);
     return FALSE;
 }
+
+/******************************************************************
+ *		CreatePipe (KERNEL32.@)
+ *
+ */
+BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
+                        LPSECURITY_ATTRIBUTES sa, DWORD size )
+{
+    static unsigned  index = 0;
+    char        name[64];
+    HANDLE      hr, hw;
+    unsigned    in_index = index;
+
+    *hReadPipe = *hWritePipe = INVALID_HANDLE_VALUE;
+    /* generate a unique pipe name (system wide) */
+    do
+    {
+        sprintf(name, "\\\\.\\pipe\\Win32.Pipes.%08lu.%08u", GetCurrentProcessId(), ++index);
+        hr = CreateNamedPipeA(name, PIPE_ACCESS_INBOUND, 
+                              PIPE_TYPE_BYTE | PIPE_WAIT, 1, size, size, 
+                              NMPWAIT_USE_DEFAULT_WAIT, sa);
+    } while (hr == INVALID_HANDLE_VALUE && index != in_index);
+    /* from completion sakeness, I think system resources might be exhausted before this happens !! */
+    if (hr == INVALID_HANDLE_VALUE) return FALSE;
+
+    hw = CreateFileA(name, GENERIC_WRITE, 0, sa, OPEN_EXISTING, 0, 0);
+    if (hw == INVALID_HANDLE_VALUE) 
+    {
+        CloseHandle(hr);
+        return FALSE;
+    }
+
+    *hReadPipe = hr;
+    *hWritePipe = hw;
+    return TRUE;
+}
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/ntdll25/Makefile.in dlls/ntdll/Makefile.in
--- dlls/ntdll25/Makefile.in	2003-05-17 22:05:39.000000000 +0200
+++ dlls/ntdll/Makefile.in	2003-05-19 22:00:35.000000000 +0200
@@ -52,7 +52,6 @@
 	$(TOPOBJDIR)/scheduler/critsection.c \
 	$(TOPOBJDIR)/scheduler/fiber.c \
 	$(TOPOBJDIR)/scheduler/handle.c \
-	$(TOPOBJDIR)/scheduler/pipe.c \
 	$(TOPOBJDIR)/scheduler/process.c \
 	$(TOPOBJDIR)/scheduler/pthread.c \
 	$(TOPOBJDIR)/scheduler/synchro.c \
diff -u -N -r -x '*~' -x '.#*' -x CVS server25/Makefile.in server/Makefile.in
--- server25/Makefile.in	2003-03-26 20:45:44.000000000 +0100
+++ server/Makefile.in	2003-05-19 21:58:57.000000000 +0200
@@ -25,7 +25,6 @@
 	mutex.c \
 	named_pipe.c \
 	object.c \
-	pipe.c \
 	process.c \
 	ptrace.c \
 	queue.c \
diff -u -N -r -x '*~' -x '.#*' -x CVS server25/protocol.def server/protocol.def
--- server25/protocol.def	2003-05-15 20:34:06.000000000 +0200
+++ server/protocol.def	2003-05-19 22:25:50.000000000 +0200
@@ -712,15 +712,6 @@
 @END
 
 
-/* Create an anonymous pipe */
- at REQ(create_pipe)
-    int          inherit;       /* inherit flag */
- at REPLY
-    obj_handle_t handle_read;   /* handle to the read-side of the pipe */
-    obj_handle_t handle_write;  /* handle to the write-side of the pipe */
- at END
-
-
 /* Create a socket */
 @REQ(create_socket)
     unsigned int access;        /* wanted access rights */


More information about the wine-patches mailing list