On 10/12/2020 2:02 PM, Ken Brown via Cygwin-patches wrote: > It looks to me like there's been a bug in the MSG_WAITALL support for > AF_INET and AF_LOCAL sockets ever since that support was first > introduced 13 years ago in commit 023a2fa7. If I'm right, MSG_WAITALL > has never worked. > > This patch fixes it. I'll push it in a few days if no one sees > anything wrong with it. > > In a followup email I'll show how I tested it. Attached are slight variants of the server/client programs from Section 57.2 of Kerrisk's book, "The Linux Programming Interface". The only essential difference is that I've changed the server program to (a) use a small buffer (size 10 instead of 100) and (b) use 'recv' with the MSG_WAITALL flag instead of 'read'. The 'recv' call shouldn't return until it reads 10 bytes. To test, run waitall_sv in one terminal and waitall_cl in a second. Type something in the second terminal (followed by RET), and it should be echoed in the first. But because of the MSG_WAITALL flag, the echoing shouldn't occur until 10 bytes have been written. For example, if I type "abcd" in the second terminal and then do it again, I should see the following: # Terminal 2: $ ./waitall_cl abcd abcd # Terminal 1: $ ./waitall_sv abcd abcd Here the echoing in Terminal 1 shouldn't occur until I've typed both "abcd" lines in Terminal 2. [Note that there is a newline character after each "abcd", so "abcd" is 5 bytes long, and the two lines together are 10 bytes long.] Before I apply my patch, each line typed in Terminal 2 is immediately echoed in Terminal 1. After I apply the patch, the echoing doesn't occur until I've typed both lines. Ken