Rebase against 1cc93e3f05bce5ae9758fad44f69f44e1462d81b.

This commit is contained in:
Sebastian Lackner
2017-02-23 14:23:18 +01:00
parent 4136b55f1c
commit 5b58419a0e
12 changed files with 536 additions and 655 deletions

View File

@@ -1,4 +1,4 @@
From 6f7aea78c09e8c1ef0e93aef214ac28fe223d544 Mon Sep 17 00:00:00 2001
From a6015c0c962802b44e1bf918e454745f1cc377b8 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 4 Aug 2014 05:01:11 +0200
Subject: server: Use SOCK_SEQPACKET socket in combination with SO_PEEK_OFF to
@@ -36,10 +36,10 @@ Changes in v6:
create mode 100644 server/sock.h
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 11626a2..0a3f2d7 100644
index 494db9c1a31..38aaccfa55c 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -1470,7 +1470,7 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
@@ -1475,7 +1475,7 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
ULONG read_size = io.Information - FIELD_OFFSET( FILE_PIPE_PEEK_BUFFER, Data );
if (lpcbAvail) *lpcbAvail = buffer->ReadDataAvailable;
if (lpcbRead) *lpcbRead = read_size;
@@ -49,10 +49,10 @@ index 11626a2..0a3f2d7 100644
}
else SetLastError( RtlNtStatusToDosError(status) );
diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c
index 544b7fa..5f5553b 100644
index e7cfce4c00e..71d75be90e8 100644
--- a/dlls/kernel32/tests/pipe.c
+++ b/dlls/kernel32/tests/pipe.c
@@ -286,7 +286,6 @@ static void test_CreateNamedPipe(int pipemode)
@@ -294,7 +294,6 @@ static void test_CreateNamedPipe(int pipemode)
if (pipemode == PIPE_TYPE_BYTE)
ok(leftmsg == 0, "peek got %d bytes left in message\n", leftmsg);
else
@@ -60,7 +60,7 @@ index 544b7fa..5f5553b 100644
ok(leftmsg == sizeof(obuf2) - 4, "peek got %d bytes left in message\n", leftmsg);
ok(ReadFile(hFile, ibuf + 4, sizeof(ibuf) - 4, &readden, NULL), "ReadFile\n");
ok(readden == sizeof(obuf2) - 4, "read got %d bytes\n", readden);
@@ -357,7 +356,7 @@ static void test_CreateNamedPipe(int pipemode)
@@ -365,7 +364,7 @@ static void test_CreateNamedPipe(int pipemode)
}
else
{
@@ -69,7 +69,7 @@ index 544b7fa..5f5553b 100644
}
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek3 got %d bytes available\n", avail);
pbuf = ibuf;
@@ -385,7 +384,7 @@ static void test_CreateNamedPipe(int pipemode)
@@ -393,7 +392,7 @@ static void test_CreateNamedPipe(int pipemode)
}
else
{
@@ -78,7 +78,7 @@ index 544b7fa..5f5553b 100644
}
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek4 got %d bytes available\n", avail);
pbuf = ibuf;
@@ -426,7 +425,7 @@ static void test_CreateNamedPipe(int pipemode)
@@ -434,7 +433,7 @@ static void test_CreateNamedPipe(int pipemode)
ok(WriteFile(hnp, obuf2, sizeof(obuf2), &written, NULL), " WriteFile5b\n");
ok(written == sizeof(obuf2), "write file len 3b\n");
ok(PeekNamedPipe(hFile, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek5\n");
@@ -87,7 +87,7 @@ index 544b7fa..5f5553b 100644
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek5 got %d bytes available\n", avail);
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 5a check\n");
@@ -458,7 +457,7 @@ static void test_CreateNamedPipe(int pipemode)
@@ -466,7 +465,7 @@ static void test_CreateNamedPipe(int pipemode)
ok(WriteFile(hFile, obuf2, sizeof(obuf2), &written, NULL), " WriteFile6b\n");
ok(written == sizeof(obuf2), "write file len 6b\n");
ok(PeekNamedPipe(hnp, ibuf, sizeof(ibuf), &readden, &avail, NULL), "Peek6\n");
@@ -96,7 +96,7 @@ index 544b7fa..5f5553b 100644
ok(avail == sizeof(obuf) + sizeof(obuf2), "peek6b got %d bytes available\n", avail);
pbuf = ibuf;
ok(memcmp(obuf, pbuf, sizeof(obuf)) == 0, "content 6a check\n");
@@ -510,12 +509,10 @@ static void test_CreateNamedPipe(int pipemode)
@@ -518,12 +517,10 @@ static void test_CreateNamedPipe(int pipemode)
readden = leftmsg = -1;
ok(PeekNamedPipe(hFile, NULL, 0, NULL, &readden, &leftmsg), "PeekNamedPipe 9\n");
ok(readden == sizeof(obuf) + sizeof(obuf2), "peek got %d bytes total 9\n", readden);
@@ -109,7 +109,7 @@ index 544b7fa..5f5553b 100644
ok(leftmsg == sizeof(obuf), "peek got %d bytes left in message 9\n", leftmsg);
SetLastError(0xdeadbeef);
todo_wine
@@ -533,12 +530,10 @@ static void test_CreateNamedPipe(int pipemode)
@@ -541,12 +538,10 @@ static void test_CreateNamedPipe(int pipemode)
readden = leftmsg = -1;
ok(PeekNamedPipe(hFile, NULL, 0, NULL, &readden, &leftmsg), "PeekNamedPipe 9\n");
ok(readden == sizeof(obuf) - 8 + sizeof(obuf2), "peek got %d bytes total 9\n", readden);
@@ -122,7 +122,7 @@ index 544b7fa..5f5553b 100644
ok(leftmsg == sizeof(obuf) - 8, "peek got %d bytes left in message 9\n", leftmsg);
ret = RpcReadFile(hFile, ibuf + 8, sizeof(ibuf), &readden, NULL);
ok(ret, "RpcReadFile 9\n");
@@ -599,12 +594,10 @@ static void test_CreateNamedPipe(int pipemode)
@@ -607,12 +602,10 @@ static void test_CreateNamedPipe(int pipemode)
readden = leftmsg = -1;
ok(PeekNamedPipe(hnp, NULL, 0, NULL, &readden, &leftmsg), "PeekNamedPipe 10\n");
ok(readden == sizeof(obuf) + sizeof(obuf2), "peek got %d bytes total 10\n", readden);
@@ -135,7 +135,7 @@ index 544b7fa..5f5553b 100644
ok(leftmsg == sizeof(obuf2), "peek got %d bytes left in message 10\n", leftmsg);
SetLastError(0xdeadbeef);
todo_wine
@@ -622,12 +615,10 @@ static void test_CreateNamedPipe(int pipemode)
@@ -630,12 +623,10 @@ static void test_CreateNamedPipe(int pipemode)
readden = leftmsg = -1;
ok(PeekNamedPipe(hnp, NULL, 0, NULL, &readden, &leftmsg), "PeekNamedPipe 10\n");
ok(readden == sizeof(obuf2) - 8 + sizeof(obuf), "peek got %d bytes total 10\n", readden);
@@ -149,10 +149,10 @@ index 544b7fa..5f5553b 100644
ret = RpcReadFile(hnp, ibuf + 8, sizeof(ibuf), &readden, NULL);
ok(ret, "RpcReadFile 10\n");
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index eef36ad..420984c 100644
index af582ecfdb0..42b81fb3fbb 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -91,6 +91,10 @@
@@ -96,6 +96,10 @@
# include <valgrind/memcheck.h>
#endif
@@ -163,7 +163,7 @@ index eef36ad..420984c 100644
#include "ntstatus.h"
#define WIN32_NO_STATUS
#define NONAMELESSUNION
@@ -509,18 +513,57 @@ static NTSTATUS unix_fd_avail(int fd, int *avail)
@@ -515,18 +519,57 @@ static NTSTATUS unix_fd_avail(int fd, int *avail)
STATUS_PIPE_BROKEN : STATUS_SUCCESS;
}
@@ -224,7 +224,7 @@ index eef36ad..420984c 100644
{
if (*total)
return STATUS_SUCCESS;
@@ -536,16 +579,17 @@ static NTSTATUS read_unix_fd(int fd, char *buf, ULONG *total, ULONG length,
@@ -542,16 +585,17 @@ static NTSTATUS read_unix_fd(int fd, char *buf, ULONG *total, ULONG length,
return STATUS_PIPE_BROKEN;
}
}
@@ -246,7 +246,7 @@ index eef36ad..420984c 100644
}
/***********************************************************************
@@ -1103,13 +1147,14 @@ NTSTATUS WINAPI NtReadFileScatter( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap
@@ -1127,13 +1171,14 @@ NTSTATUS WINAPI NtReadFileScatter( HANDLE file, HANDLE event, PIO_APC_ROUTINE ap
/* helper function for NtWriteFile and FILE_AsyncWriteService */
static NTSTATUS write_unix_fd(int fd, const char *buf, ULONG *total, ULONG length, enum server_fd_type type)
{
@@ -262,7 +262,7 @@ index eef36ad..420984c 100644
if (result >= 0)
{
*total += result;
@@ -1118,6 +1163,17 @@ static NTSTATUS write_unix_fd(int fd, const char *buf, ULONG *total, ULONG lengt
@@ -1142,6 +1187,17 @@ static NTSTATUS write_unix_fd(int fd, const char *buf, ULONG *total, ULONG lengt
else if (type != FD_TYPE_FILE) /* no async I/O on regular files */
return STATUS_PENDING;
}
@@ -280,7 +280,7 @@ index eef36ad..420984c 100644
else if (errno != EINTR)
{
if (errno == EAGAIN)
@@ -1708,20 +1764,40 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
@@ -1734,20 +1790,40 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
status = unix_fd_avail( fd, &avail );
if (!status)
{
@@ -329,7 +329,7 @@ index eef36ad..420984c 100644
if (needs_close) close( fd );
}
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 3e1eff0..3d9917f 100644
index c75a7379283..6c6a8b40bd1 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -42,6 +42,10 @@
@@ -351,7 +351,7 @@ index 3e1eff0..3d9917f 100644
#include "handle.h"
#include "thread.h"
#include "request.h"
@@ -799,14 +804,43 @@ static int named_pipe_link_name( struct object *obj, struct object_name *name, s
@@ -761,14 +766,43 @@ static int named_pipe_link_name( struct object *obj, struct object_name *name, s
return 1;
}
@@ -396,7 +396,7 @@ index 3e1eff0..3d9917f 100644
if (!(server = find_available_server( pipe )))
{
@@ -825,7 +859,10 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc
@@ -787,7 +821,10 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc
if ((client = create_pipe_client( options, pipe->flags )))
{
@@ -406,18 +406,13 @@ index 3e1eff0..3d9917f 100644
+
+ if (!socketpair( PF_UNIX, type, 0, fds ))
{
assert( !server->fd );
assert( !server->pipe_end.fd );
@@ -835,32 +872,55 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc
@@ -797,32 +834,55 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc
if (is_overlapped( options )) fcntl( fds[1], F_SETFL, O_NONBLOCK );
if (is_overlapped( server->options )) fcntl( fds[0], F_SETFL, O_NONBLOCK );
- if (pipe->insize)
- {
- setsockopt( fds[0], SOL_SOCKET, SO_RCVBUF, &pipe->insize, sizeof(pipe->insize) );
- setsockopt( fds[1], SOL_SOCKET, SO_RCVBUF, &pipe->insize, sizeof(pipe->insize) );
- }
- if (pipe->outsize)
+ /* FIXME: For message mode we don't pay attention to the provided buffer size.
+ * Linux pipes cannot dynamically adjust size, so we leave the size to the system
+ * instead of using the application provided value. Please note that this will
@@ -425,6 +420,11 @@ index 3e1eff0..3d9917f 100644
+ * messages. */
+ if (type != SOCK_SEQPACKET)
{
- setsockopt( fds[0], SOL_SOCKET, SO_RCVBUF, &pipe->insize, sizeof(pipe->insize) );
- setsockopt( fds[1], SOL_SOCKET, SO_RCVBUF, &pipe->insize, sizeof(pipe->insize) );
- }
- if (pipe->outsize)
- {
- setsockopt( fds[0], SOL_SOCKET, SO_SNDBUF, &pipe->outsize, sizeof(pipe->outsize) );
- setsockopt( fds[1], SOL_SOCKET, SO_SNDBUF, &pipe->outsize, sizeof(pipe->outsize) );
+ if (pipe->insize)
@@ -439,32 +439,32 @@ index 3e1eff0..3d9917f 100644
+ }
}
- client->fd = create_anonymous_fd( &pipe_client_fd_ops, fds[1], &client->obj, options );
- server->fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->obj, server->options );
- if (client->fd && server->fd)
- client->pipe_end.fd = create_anonymous_fd( &pipe_client_fd_ops, fds[1], &client->pipe_end.obj, options );
- server->pipe_end.fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->pipe_end.obj, server->options );
- if (client->pipe_end.fd && server->pipe_end.fd)
+ if (type != SOCK_SEQPACKET || (setsockopt( fds[0], SOL_SOCKET, SO_PEEK_OFF, &zero, sizeof(zero) ) != -1 &&
+ setsockopt( fds[1], SOL_SOCKET, SO_PEEK_OFF, &zero, sizeof(zero) ) != -1))
{
- allow_fd_caching( client->fd );
- allow_fd_caching( server->fd );
- fd_copy_completion( server->ioctl_fd, server->fd );
- allow_fd_caching( client->pipe_end.fd );
- allow_fd_caching( server->pipe_end.fd );
- fd_copy_completion( server->ioctl_fd, server->pipe_end.fd );
- if (server->state == ps_wait_open)
- fd_async_wake_up( server->ioctl_fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
- set_server_state( server, ps_connected_server );
- server->client = client;
- client->server = server;
+ #ifdef __linux__
+ fcntl( fds[0], F_SETSIG, messagemode_flags( server->pipe_flags ) );
+ fcntl( fds[1], F_SETSIG, messagemode_flags( client->pipe_flags ) );
+ fcntl( fds[0], F_SETSIG, messagemode_flags( server->pipe_end.flags ) );
+ fcntl( fds[1], F_SETSIG, messagemode_flags( client->pipe_end.flags ) );
+ #endif
+
+ client->fd = create_anonymous_fd( &pipe_client_fd_ops, fds[1], &client->obj, options );
+ server->fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->obj, server->options );
+ if (client->fd && server->fd)
+ client->pipe_end.fd = create_anonymous_fd( &pipe_client_fd_ops, fds[1], &client->pipe_end.obj, options );
+ server->pipe_end.fd = create_anonymous_fd( &pipe_server_fd_ops, fds[0], &server->pipe_end.obj, server->options );
+ if (client->pipe_end.fd && server->pipe_end.fd)
+ {
+ allow_fd_caching( client->fd );
+ allow_fd_caching( server->fd );
+ fd_copy_completion( server->ioctl_fd, server->fd );
+ allow_fd_caching( client->pipe_end.fd );
+ allow_fd_caching( server->pipe_end.fd );
+ fd_copy_completion( server->ioctl_fd, server->pipe_end.fd );
+ if (server->state == ps_wait_open)
+ fd_async_wake_up( server->ioctl_fd, ASYNC_TYPE_WAIT, STATUS_SUCCESS );
+ set_server_state( server, ps_connected_server );
@@ -483,7 +483,7 @@ index 3e1eff0..3d9917f 100644
release_object( client );
client = NULL;
}
@@ -951,7 +1011,7 @@ DECL_HANDLER(create_named_pipe)
@@ -907,7 +967,7 @@ DECL_HANDLER(create_named_pipe)
return;
}
@@ -492,7 +492,7 @@ index 3e1eff0..3d9917f 100644
if (!name.len) /* pipes need a root directory even without a name */
{
@@ -1054,6 +1114,9 @@ DECL_HANDLER(set_named_pipe_info)
@@ -1010,6 +1070,9 @@ DECL_HANDLER(set_named_pipe_info)
{
struct pipe_server *server;
struct pipe_client *client = NULL;
@@ -502,29 +502,29 @@ index 3e1eff0..3d9917f 100644
server = get_pipe_server_obj( current->process, req->handle, FILE_WRITE_ATTRIBUTES );
if (!server)
@@ -1080,10 +1143,20 @@ DECL_HANDLER(set_named_pipe_info)
@@ -1036,10 +1099,20 @@ DECL_HANDLER(set_named_pipe_info)
else if (client)
{
client->pipe_flags = server->pipe->flags | req->flags;
client->pipe_end.flags = server->pipe->flags | req->flags;
+ #ifdef __linux__
+ if (client->fd && (unix_fd = get_unix_fd( client->fd )) != -1)
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( client->pipe_flags ) );
+ if (client->pipe_end.fd && (unix_fd = get_unix_fd( client->pipe_end.fd )) != -1)
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( client->pipe_end.flags ) );
+ clear_error();
+ #endif
}
else
{
server->pipe_flags = server->pipe->flags | req->flags;
server->pipe_end.flags = server->pipe->flags | req->flags;
+ #ifdef __linux__
+ if (server->fd && (unix_fd = get_unix_fd( server->fd )) != -1)
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( server->pipe_flags ) );
+ if (server->pipe_end.fd && (unix_fd = get_unix_fd( server->pipe_end.fd )) != -1)
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( server->pipe_end.flags ) );
+ clear_error();
+ #endif
}
if (client)
diff --git a/server/sock.c b/server/sock.c
index a11964f..0a2e079 100644
index d6b4fb2fa5c..49b6d3d5758 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -61,6 +61,7 @@
@@ -535,7 +535,7 @@ index a11964f..0a2e079 100644
#include "handle.h"
#include "thread.h"
#include "request.h"
@@ -136,7 +137,6 @@ static int sock_cancel_async( struct fd *fd, struct process *process, struct thr
@@ -135,7 +136,6 @@ static void sock_reselect_async( struct fd *fd, struct async_queue *queue );
static int sock_get_ntstatus( int err );
static int sock_get_error( int err );
@@ -543,7 +543,7 @@ index a11964f..0a2e079 100644
static const struct object_ops sock_ops =
{
@@ -958,7 +958,7 @@ static int sock_get_ntstatus( int err )
@@ -941,7 +941,7 @@ static int sock_get_ntstatus( int err )
}
/* set the last error depending on errno */
@@ -554,7 +554,7 @@ index a11964f..0a2e079 100644
}
diff --git a/server/sock.h b/server/sock.h
new file mode 100644
index 0000000..21551b4
index 00000000000..21551b42b1c
--- /dev/null
+++ b/server/sock.h
@@ -0,0 +1,26 @@
@@ -585,5 +585,5 @@ index 0000000..21551b4
+
+#endif /* __WINE_SERVER_SOCK_H */
--
2.7.0
2.11.0

View File

@@ -1,4 +1,4 @@
From 8bba3ddd8ee9234d7c1f9d21b2aa3f4cdcdd1b3a Mon Sep 17 00:00:00 2001
From 260d35bbb99549c5ebf8447f6f1bf0680f6e3943 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 6 Jun 2015 01:21:05 +0200
Subject: server: Return correct error codes for NtWriteFile when pipes are
@@ -39,10 +39,10 @@ index ab34d99d5b6..d0662d9ae59 100644
}
}
diff --git a/server/named_pipe.c b/server/named_pipe.c
index e480f31a00e..eccf6a463f5 100644
index 6c6a8b40bd1..47a88790fa3 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -147,6 +147,7 @@ static const struct object_ops named_pipe_ops =
@@ -150,6 +150,7 @@ static const struct object_ops named_pipe_ops =
/* server end functions */
static void pipe_server_dump( struct object *obj, int verbose );
static struct fd *pipe_server_get_fd( struct object *obj );
@@ -50,7 +50,7 @@ index e480f31a00e..eccf6a463f5 100644
static void pipe_server_destroy( struct object *obj);
static obj_handle_t pipe_server_flush( struct fd *fd, struct async *async, int blocking );
static enum server_fd_type pipe_server_get_fd_type( struct fd *fd );
@@ -172,7 +173,7 @@ static const struct object_ops pipe_server_ops =
@@ -175,7 +176,7 @@ static const struct object_ops pipe_server_ops =
NULL, /* unlink_name */
no_open_file, /* open_file */
no_alloc_handle, /* alloc_handle */
@@ -59,7 +59,7 @@ index e480f31a00e..eccf6a463f5 100644
pipe_server_destroy /* destroy */
};
@@ -193,6 +194,7 @@ static const struct fd_ops pipe_server_fd_ops =
@@ -196,6 +197,7 @@ static const struct fd_ops pipe_server_fd_ops =
static void pipe_client_dump( struct object *obj, int verbose );
static int pipe_client_signaled( struct object *obj, struct wait_queue_entry *entry );
static struct fd *pipe_client_get_fd( struct object *obj );
@@ -67,7 +67,7 @@ index e480f31a00e..eccf6a463f5 100644
static void pipe_client_destroy( struct object *obj );
static obj_handle_t pipe_client_flush( struct fd *fd, struct async *async, int blocking );
static enum server_fd_type pipe_client_get_fd_type( struct fd *fd );
@@ -216,7 +218,7 @@ static const struct object_ops pipe_client_ops =
@@ -219,7 +221,7 @@ static const struct object_ops pipe_client_ops =
NULL, /* unlink_name */
no_open_file, /* open_file */
no_alloc_handle, /* alloc_handle */
@@ -76,7 +76,7 @@ index e480f31a00e..eccf6a463f5 100644
pipe_client_destroy /* destroy */
};
@@ -281,6 +283,8 @@ static const struct fd_ops named_pipe_device_fd_ops =
@@ -284,6 +286,8 @@ static const struct fd_ops named_pipe_device_fd_ops =
default_fd_reselect_async /* reselect_async */
};
@@ -85,8 +85,8 @@ index e480f31a00e..eccf6a463f5 100644
static void named_pipe_dump( struct object *obj, int verbose )
{
fputs( "Named pipe\n", stderr );
@@ -390,6 +394,23 @@ static void do_disconnect( struct pipe_server *server )
server->fd = NULL;
@@ -393,6 +397,23 @@ static void do_disconnect( struct pipe_server *server )
server->pipe_end.fd = NULL;
}
+static int pipe_server_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
@@ -97,10 +97,10 @@ index e480f31a00e..eccf6a463f5 100644
+ int unix_fd;
+
+ assert( obj->ops == &pipe_server_ops );
+ if (obj->handle_count == 1 && client && client->fd && (unix_fd = get_unix_fd( client->fd )) != -1)
+ if (obj->handle_count == 1 && client && client->pipe_end.fd && (unix_fd = get_unix_fd( client->pipe_end.fd )) != -1)
+ {
+ /* set the NAMED_PIPE_CLOSED_HANDLE flag, to distinguish disconnect / closing pipe */
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( client->pipe_flags ) | NAMED_PIPE_CLOSED_HANDLE );
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( client->pipe_end.flags ) | NAMED_PIPE_CLOSED_HANDLE );
+ }
+#endif
+ return 1;
@@ -109,7 +109,7 @@ index e480f31a00e..eccf6a463f5 100644
static void pipe_server_destroy( struct object *obj)
{
struct pipe_server *server = (struct pipe_server *)obj;
@@ -416,6 +437,24 @@ static void pipe_server_destroy( struct object *obj)
@@ -419,6 +440,24 @@ static void pipe_server_destroy( struct object *obj)
release_object( server->pipe );
}
@@ -121,11 +121,11 @@ index e480f31a00e..eccf6a463f5 100644
+ int unix_fd;
+
+ assert( obj->ops == &pipe_client_ops );
+ if (obj->handle_count == 1 && server && server->fd &&
+ server->state != ps_wait_connect && (unix_fd = get_unix_fd( server->fd )) != -1)
+ if (obj->handle_count == 1 && server && server->pipe_end.fd &&
+ server->state != ps_wait_connect && (unix_fd = get_unix_fd( server->pipe_end.fd )) != -1)
+ {
+ /* set the NAMED_PIPE_CLOSED_HANDLE flag, to distinguish disconnect / closing pipe */
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( server->pipe_flags ) | NAMED_PIPE_CLOSED_HANDLE );
+ fcntl( unix_fd, F_SETSIG, messagemode_flags( server->pipe_end.flags ) | NAMED_PIPE_CLOSED_HANDLE );
+ }
+#endif
+ return 1;

View File

@@ -1,4 +1,4 @@
From c108a14664db758d26cffd022a8c9255b6c47b1c Mon Sep 17 00:00:00 2001
From 7fce25b8259f816e1cc8c2c40b6a73379f2fb4ef Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 24 Feb 2016 15:45:09 +0100
Subject: server: Do not allow to queue async operation for broken pipes.
@@ -8,10 +8,10 @@ Subject: server: Do not allow to queue async operation for broken pipes.
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/server/named_pipe.c b/server/named_pipe.c
index eccf6a463f5..2f1a8c8fb99 100644
index 47a88790fa3..e5c5c4968c4 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -153,6 +153,7 @@ static obj_handle_t pipe_server_flush( struct fd *fd, struct async *async, int b
@@ -156,6 +156,7 @@ static obj_handle_t pipe_server_flush( struct fd *fd, struct async *async, int b
static enum server_fd_type pipe_server_get_fd_type( struct fd *fd );
static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *async,
int blocking );
@@ -19,7 +19,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
static const struct object_ops pipe_server_ops =
{
@@ -186,7 +187,7 @@ static const struct fd_ops pipe_server_fd_ops =
@@ -189,7 +190,7 @@ static const struct fd_ops pipe_server_fd_ops =
no_fd_write, /* write */
pipe_server_flush, /* flush */
pipe_server_ioctl, /* ioctl */
@@ -28,7 +28,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
default_fd_reselect_async /* reselect_async */
};
@@ -198,6 +199,7 @@ static int pipe_client_close_handle( struct object *obj, struct process *process
@@ -201,6 +202,7 @@ static int pipe_client_close_handle( struct object *obj, struct process *process
static void pipe_client_destroy( struct object *obj );
static obj_handle_t pipe_client_flush( struct fd *fd, struct async *async, int blocking );
static enum server_fd_type pipe_client_get_fd_type( struct fd *fd );
@@ -36,7 +36,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
static const struct object_ops pipe_client_ops =
{
@@ -231,7 +233,7 @@ static const struct fd_ops pipe_client_fd_ops =
@@ -234,7 +236,7 @@ static const struct fd_ops pipe_client_fd_ops =
no_fd_write, /* write */
pipe_client_flush, /* flush */
default_fd_ioctl, /* ioctl */
@@ -45,7 +45,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
default_fd_reselect_async /* reselect_async */
};
@@ -620,6 +622,20 @@ static obj_handle_t pipe_client_flush( struct fd *fd, struct async *async, int b
@@ -630,6 +632,20 @@ static obj_handle_t pipe_client_flush( struct fd *fd, struct async *async, int b
return 0;
}
@@ -54,7 +54,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
+ struct pipe_client *client = get_fd_user( fd );
+ struct pipe_server *server = client->server;
+
+ if (!server || !server->fd)
+ if (!server || !server->pipe_end.fd)
+ {
+ set_error( STATUS_PIPE_BROKEN );
+ return;
@@ -66,7 +66,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
static inline int is_overlapped( unsigned int options )
{
return !(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
@@ -705,6 +721,20 @@ static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct
@@ -714,6 +730,20 @@ static obj_handle_t pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct
}
}
@@ -75,7 +75,7 @@ index eccf6a463f5..2f1a8c8fb99 100644
+ struct pipe_server *server = get_fd_user( fd );
+ struct pipe_client *client = server->client;
+
+ if (!client || !client->fd)
+ if (!client || !client->pipe_end.fd)
+ {
+ set_error( STATUS_PIPE_BROKEN );
+ return;