A while ago, I noticed that our setup program didn't work
with cvs wine. Somebody said "Oh, that's because named pipes
are broken." Since then, the setup program works again with
cvs wine, but I'm still curious about the state of named pipes.
The simple sequence
CreateNamedPipe
CreateFile
seems to work under Windows, but not under Wine.
Does Wine for some reason require a ConnectNamedPipe between the two?
A very simple test is attached.
(BTW, I've been looking at the wineserver named pipe code a bit.
Shame it's not better commented... at least it's small, so the lack
of comments isn't too awful.)
- Dan
--
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045
Index: dlls/kernel/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/Makefile.in,v
retrieving revision 1.6
diff -u -p -u -r1.6 Makefile.in
--- dlls/kernel/tests/Makefile.in 4 Oct 2002 17:42:27 -0000 1.6
+++ dlls/kernel/tests/Makefile.in 13 Feb 2003 16:54:45 -0000
@@ -17,6 +17,7 @@ CTESTS = \
generated.c \
locale.c \
path.c \
+ pipe.c \
process.c \
thread.c
--- /dev/null 2002-08-30 16:31:37.000000000 -0700
+++ dlls/kernel/tests/pipe.c 2003-02-17 17:26:42.000000000 -0800
@@ -0,0 +1,80 @@
+/*
+ * Unit tests for named pipe functions in Wine
+ *
+ * Copyright (c) 2002 Dan Kegel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+#ifndef STANDALONE
+#include "wine/test.h"
+#else
+#include <assert.h>
+#define START_TEST(name) main(int argc, char **argv)
+#define ok(condition, msg) assert(condition)
+#endif
+
+#include <windef.h>
+#include <winbase.h>
+#include <winerror.h>
+#include <wtypes.h>
+
+#define PIPENAME "\\.\PIPE\tests_pipe"
+
+void test_CreateNamedPipeA(void)
+{
+ HANDLE hnp;
+ HANDLE hFile;
+
+ /* Functional checks
+ * Just check things used internally by wine, in e.g.
+ * wine/dlls/ole32/compobj.c
+ * wine/programs/rpcss/np_server.c
+ * wine/dlls/rpcrt4/rpc_binding.c
+ */
+
+ hnp = CreateNamedPipeA(PIPENAME,
+ PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE|PIPE_WAIT,
+ PIPE_UNLIMITED_INSTANCES,
+ 4096,
+ 4096,
+ NMPWAIT_USE_DEFAULT_WAIT,
+ NULL);
+ ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed");
+
+ /* in wine, the CreateFile is in a different thread, but that
+ * shouldn't matter. Also, the first thread does a ConnectNamedPipe,
+ * but that isn't required by the Win32 API, it's optional.
+ */
+ hFile = CreateFileA(PIPENAME, GENERIC_READ|GENERIC_WRITE, 0,
+ NULL, OPEN_EXISTING, 0, 0);
+ ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed");
+
+ if (hFile != INVALID_HANDLE_VALUE) {
+ CloseHandle(hFile);
+ }
+
+ CloseHandle(hnp);
+}
+
+START_TEST(pipe)
+{
+ test_CreateNamedPipeA();
+}
+