http://bugs.winehq.org/show_bug.cgi?id=33656
Bug #: 33656 Summary: NamedPipe datagrams need to be _really_ datagrams Product: Wine Version: unspecified Platform: Other OS/Version: other Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: joe_rocks@hotmail.com CC: adam.r.martinson@gmail.com, adys.wh@gmail.com, asb@asbradbury.org, berillions@gmail.com, dank@kegel.com, davilando@gmail.com, djelinski1@gmail.com, ernst@planetcoms.co.za, euug3576+winebugs@gmail.com, focht@gmx.net, grinnz@gmail.com, jjmckenzie51@gmail.com, jonnybarnes@gmail.com, knaprigt@gmail.com, kyle.devir@gmx.com, lkcl@lkcl.net, l_bratch@yahoo.co.uk, m.b.lankhorst@gmail.com, mooroon2@mail.ru, napoliste@gmail.com, rmlipman@gmail.com, saulius2@gmail.com, surfing86@live.it, techtonik@gmail.com, trilavia@gmail.com, update.microsoft@mail.ru, valentyn.pavliuchenko@gmail.com, vegarh@gmail.com Classification: Unclassified
+++ This bug was initially created as a clone of Bug #17195 +++
ok, after a little bit of investigation, i think i understand the pipes code enough to be able to say what's going on, and i'm seeing something like this:
process 1:
recvpipe = CreateNamedPipe("\pipe\fred") ReadFile(recvpipe, buffer, &length); printf(length) ===> 43 ReadPipe(recvpipe, buffer, &length); /* no data */
process 2:
sendpipe = CreateNamedPipe("\pipe\fred") length = 9; WriteFile(sendpipe, buffer, &length); length = 34; WriteFile(sendpipe, buffer, &length);
what's happening is that the data being sent down the pipes isn't being done as datagrams. the implementation is using a stream-based fd.
the solution is: you _must_ implement a protocol on top of the pipes which sends the length (as a 32-bit int, whatever) which is read off the fd, followed by the data stream of _exactly_ that length.
_must_. there's no two ways about this.
the protocol of Pipes is unfortunately a combination of both datagrams and streams. datagrams because the lengths of data sent are absolute and inviolate. streams because the data order and reliability are _also_ absolute and inviolate.
you can't use datagrams (because they're unreliable). you can't expect all unixen to support datagrams on top of unix sockets (if that's what's being used).
so - you have to send the length, as part of the implementation of the pipe-data-send.
sending a length will also solve the issue of trying to send zero-length pipe datagrams.
as a first implementation, you _might_ be able to get away with assuming that when someone asks for some data, they _will_ provide a buffer big enough.
... actually... i don't see any ERR_MORE_DATA error codes in NtReadFile, so that would explain... this is going to get messy :)