ntdll: Use send(2) instead of write(2) for zero-byte writes to sockets.
diff --git a/dlls/kernel32/tests/mailslot.c b/dlls/kernel32/tests/mailslot.c index 6eb8d8a..995f144 100644 --- a/dlls/kernel32/tests/mailslot.c +++ b/dlls/kernel32/tests/mailslot.c
@@ -258,8 +258,8 @@ dwNext = dwMsgCount = 0; ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ), "getmailslotinfo failed\n"); - todo_wine { ok( dwNext == 0, "dwNext incorrect\n"); + todo_wine { ok( dwMsgCount == 1, "dwMsgCount incorrect\n"); }
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c index 65710c5..0a7eccb 100644 --- a/dlls/ntdll/file.c +++ b/dlls/ntdll/file.c
@@ -668,6 +668,7 @@ { async_fileio *fileio = (async_fileio *) ovp; int result, fd, needs_close; + enum server_fd_type type; TRACE("(%p %p 0x%x)\n",iosb, fileio->buffer, status); @@ -676,12 +677,16 @@ case STATUS_ALERTED: /* write some data (non-blocking) */ if ((status = server_get_unix_fd( fileio->handle, FILE_WRITE_DATA, &fd, - &needs_close, NULL, NULL ))) + &needs_close, &type, NULL ))) { fileio_terminate(fileio, iosb, status); break; } - result = write(fd, &fileio->buffer[fileio->already], fileio->count - fileio->already); + if (!fileio->count && (type == FD_TYPE_MAILSLOT || type == FD_TYPE_PIPE || type == FD_TYPE_SOCKET)) + result = send( fd, fileio->buffer, 0, 0 ); + else + result = write( fd, &fileio->buffer[fileio->already], fileio->count - fileio->already ); + if (needs_close) close( fd ); if (result < 0) @@ -772,7 +777,13 @@ for (;;) { - if ((result = write( unix_handle, (const char *)buffer + total, length - total )) >= 0) + /* zero-length writes on sockets may not work with plain write(2) */ + if (!length && (type == FD_TYPE_MAILSLOT || type == FD_TYPE_PIPE || type == FD_TYPE_SOCKET)) + result = send( unix_handle, buffer, 0, 0 ); + else + result = write( unix_handle, (const char *)buffer + total, length - total ); + + if (result >= 0) { total += result; if (total == length)