From: Henry N. <Henry.Ne@Arcor.de> - 2005-05-12 07:46:33
|
Promblem founded. It's a feature of XP, not a bug of NT :-( Henry Nestler wrote: > Second, see in debug messages. The text says "larger than requested". > But is not larger. Received is less than. ?-( > > Source line: > if ((iodata->transferred += transferred) != iodata->transfer) > co_debug... > > Variables: > iodata->transferred: 8068 ... 8068 bytes: Based on pipe PeekNamedPipe > transferred: 8048 ... 8048 bytes: on NT can only one message read, because pipe is Message based created. > iodata->transfer: 8088 > > I do not understand all lines, As idea I tried change this in function > io_readCompletion to make, what the debug string says "error if larger": > --- bjh/src/colinux/os/winnt/user/daemon.c > +++ hn/src/colinux/os/winnt/user/daemon.c > @@ -158,7 +158,7 @@ > return; > } > } > - if ((iodata->transferred += transferred) != iodata->transfer) { > + if ((iodata->transferred += transferred) > iodata->transfer) { > co_debug_lvl(pipe,10,"io transfer larger than requested > itd=%d td=%d t=%d", iodata-> > iodata->iostate = io_error; > iodata->rc = CO_RC(ERROR); > > > Patch for 0.6.3-pre10 attached. > This reverts the revert from > Revision: 89f25652f81b4c2dd80f5f810a2c4808fd2e5273 > Date: 2005-03-22T14:37:48 Second patch is also. > This works on W2K and XP! > Johnathan, please can you confirm this as simple typofix? > Or must the request size exactly the transferred size, think no? One sample of NT: PeekNamedPipe returned with 30, 20 as sizeof (co_message_t) and 10 for data. The follow function ReadFileEx reads only 20 Bytes, over back called io_readCompletion. The 10 bytes of Data beleves in pipe. State machine detects this and calls the ReadFileEx again. This reads the last 10 bytes. Under XP PeekNamedPipe returned 30 and ReadFileEx reads this 30 bytes in one call of callback funtion io_readCompletion. Daemon Pipe is opened as default type. Default is PIPE_TYPE_MESSAGE (see CreateNamedPipe). Have check this with GetNamedPipeInfo. Both XP and NT2000 returned with lpFlags 4 = PIPE_TYPE_MESSAGE. On other side the GetNamedPipeHandleState sayed pipe opend as PIPE_READMODE_BYTE. XP ignored the pipe creator and read the pipe as byte stream. NT use the creator settings and read the pipe message by message. Is more as confious. SetNamedPipeHandleState can't change the read mode on NT into byte stream mode (PIPE_TYPE_BYTE). No errors, and mode not changed. On XP can change the read mode to PIPE_READMODE_MESSAGE. Aha! Than have the same problem of beginning this thread here. :-( My last implementation is correct. io_readCompletion should also read an incomplete byte count (different and less than count return from PeekNamedPipe). Is good implementation for XP and NT2000. Under XP and NT we should set the PIPE_READMODE_MESSAGE. This give the same pipe handling under XP and NT: Read single Message. But peek give of summary of bytes of all messages in pipe (see MS SDK). This lines are added in "bjh i/o" patch today. >>> co-stable/src/colinux/os/winnt/user/daemon.c >>> handle = CreateFile(pathname, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); if (handle == INVALID_HANDLE_VALUE) goto co_os_open_daemon_pipe_error; + long lpMode = PIPE_READMODE_MESSAGE; + if (!SetNamedPipeHandleState(handle, &lpMode, 0, 0)) + co_debug_lvl(pipe,10,"error %x SetNamedPipeHandleState", GetLastError()); /* Identify ourselves to the daemon */ if (!WriteFile(handle, &module_id, sizeof (module_id), &written, NULL)) { co_debug("attachment failed\n"); goto co_os_open_daemon_pipe_error; <<< end <<< A new pre version will upload in some hours http://www.henrynestler.com/colinux/binary/stable-0.6.3-pre10-hn2/ Puh. What a big hack for small changes! George, you can commit the attached full patch now. For all others, please check the implementation on devel for this mistaken. --- * Remark from MS SDK describe the missure: The data is read in the mode specified with CreateNamedPipe. For example, create a pipe with PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE. If you change the mode to PIPE_READMODE_BYTE with SetNamedPipeHandleState, ReadFile will read in byte mode, but PeekNamedPipe will continue to read in message mode. -- Henry Nestler |