Commit c915215b authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Use send(2) instead of write(2) for zero-byte writes to sockets.

parent d5787256
...@@ -258,8 +258,8 @@ static int mailslot_test(void) ...@@ -258,8 +258,8 @@ static int mailslot_test(void)
dwNext = dwMsgCount = 0; dwNext = dwMsgCount = 0;
ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ), ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
"getmailslotinfo failed\n"); "getmailslotinfo failed\n");
todo_wine {
ok( dwNext == 0, "dwNext incorrect\n"); ok( dwNext == 0, "dwNext incorrect\n");
todo_wine {
ok( dwMsgCount == 1, "dwMsgCount incorrect\n"); ok( dwMsgCount == 1, "dwMsgCount incorrect\n");
} }
......
...@@ -668,6 +668,7 @@ static void WINAPI FILE_AsyncWriteService(void *ovp, IO_STATUS_BLOCK *iosb, ULON ...@@ -668,6 +668,7 @@ static void WINAPI FILE_AsyncWriteService(void *ovp, IO_STATUS_BLOCK *iosb, ULON
{ {
async_fileio *fileio = (async_fileio *) ovp; async_fileio *fileio = (async_fileio *) ovp;
int result, fd, needs_close; int result, fd, needs_close;
enum server_fd_type type;
TRACE("(%p %p 0x%x)\n",iosb, fileio->buffer, status); TRACE("(%p %p 0x%x)\n",iosb, fileio->buffer, status);
...@@ -676,12 +677,16 @@ static void WINAPI FILE_AsyncWriteService(void *ovp, IO_STATUS_BLOCK *iosb, ULON ...@@ -676,12 +677,16 @@ static void WINAPI FILE_AsyncWriteService(void *ovp, IO_STATUS_BLOCK *iosb, ULON
case STATUS_ALERTED: case STATUS_ALERTED:
/* write some data (non-blocking) */ /* write some data (non-blocking) */
if ((status = server_get_unix_fd( fileio->handle, FILE_WRITE_DATA, &fd, 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); fileio_terminate(fileio, iosb, status);
break; 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 (needs_close) close( fd );
if (result < 0) if (result < 0)
...@@ -772,7 +777,13 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent, ...@@ -772,7 +777,13 @@ NTSTATUS WINAPI NtWriteFile(HANDLE hFile, HANDLE hEvent,
for (;;) 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; total += result;
if (total == length) if (total == length)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment