server: Store sharing state for named pipes.

This commit is contained in:
Bernhard Loos 2011-09-26 13:57:15 +02:00 committed by Alexandre Julliard
parent 557deb0a19
commit 039bacb0c9
7 changed files with 24 additions and 15 deletions

View file

@ -1346,7 +1346,7 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
HANDLE handle;
UNICODE_STRING nt_name;
OBJECT_ATTRIBUTES attr;
DWORD access, options;
DWORD access, options, sharing;
BOOLEAN pipe_type, read_mode, non_block;
NTSTATUS status;
IO_STATUS_BLOCK iosb;
@ -1379,15 +1379,15 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
switch(dwOpenMode & 3)
{
case PIPE_ACCESS_INBOUND:
options = FILE_PIPE_INBOUND;
sharing = FILE_SHARE_WRITE;
access = GENERIC_READ;
break;
case PIPE_ACCESS_OUTBOUND:
options = FILE_PIPE_OUTBOUND;
sharing = FILE_SHARE_READ;
access = GENERIC_WRITE;
break;
case PIPE_ACCESS_DUPLEX:
options = FILE_PIPE_FULL_DUPLEX;
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
access = GENERIC_READ | GENERIC_WRITE;
break;
default:
@ -1395,6 +1395,7 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
return INVALID_HANDLE_VALUE;
}
access |= SYNCHRONIZE;
options = 0;
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH) options |= FILE_WRITE_THROUGH;
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED)) options |= FILE_SYNCHRONOUS_IO_NONALERT;
pipe_type = (dwPipeMode & PIPE_TYPE_MESSAGE) ? TRUE : FALSE;
@ -1406,7 +1407,7 @@ HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
SetLastError(0);
status = NtCreateNamedPipeFile(&handle, access, &attr, &iosb, 0,
status = NtCreateNamedPipeFile(&handle, access, &attr, &iosb, sharing,
FILE_OVERWRITE_IF, options, pipe_type,
read_mode, non_block, nMaxInstances,
nInBufferSize, nOutBufferSize, &timeout);
@ -1847,8 +1848,8 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
GetCurrentProcessId(), ++index);
RtlInitUnicodeString(&nt_name, name);
status = NtCreateNamedPipeFile(&hr, GENERIC_READ | SYNCHRONIZE, &attr, &iosb,
0, FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_PIPE_INBOUND,
FILE_SHARE_WRITE, FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT,
FALSE, FALSE, FALSE,
1, size, size, &timeout);
if (status)

View file

@ -2781,6 +2781,7 @@ NTSTATUS WINAPI NtCreateNamedPipeFile( PHANDLE handle, ULONG access,
req->attributes = attr->Attributes;
req->rootdir = wine_server_obj_handle( attr->RootDirectory );
req->options = options;
req->sharing = sharing;
req->flags =
(pipe_type) ? NAMED_PIPE_MESSAGE_STREAM_WRITE : 0 |
(read_mode) ? NAMED_PIPE_MESSAGE_STREAM_READ : 0 |

View file

@ -3030,13 +3030,15 @@ struct create_named_pipe_request
unsigned int attributes;
obj_handle_t rootdir;
unsigned int options;
unsigned int sharing;
unsigned int maxinstances;
unsigned int outsize;
unsigned int insize;
char __pad_44[4];
timeout_t timeout;
unsigned int flags;
/* VARARG(name,unicode_str); */
char __pad_52[4];
char __pad_60[4];
};
struct create_named_pipe_reply
{
@ -5635,6 +5637,6 @@ union generic_reply
struct set_suspend_context_reply set_suspend_context_reply;
};
#define SERVER_PROTOCOL_VERSION 425
#define SERVER_PROTOCOL_VERSION 426
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View file

@ -91,6 +91,7 @@ struct named_pipe
{
struct object obj; /* object header */
unsigned int flags;
unsigned int sharing;
unsigned int maxinstances;
unsigned int outsize;
unsigned int insize;
@ -960,6 +961,7 @@ DECL_HANDLER(create_named_pipe)
pipe->maxinstances = req->maxinstances;
pipe->timeout = req->timeout;
pipe->flags = req->flags;
pipe->sharing = req->sharing;
}
else
{

View file

@ -2186,6 +2186,7 @@ enum message_type
unsigned int attributes; /* object attributes */
obj_handle_t rootdir; /* root directory */
unsigned int options;
unsigned int sharing;
unsigned int maxinstances;
unsigned int outsize;
unsigned int insize;

View file

@ -1477,12 +1477,13 @@ C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, access) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, attributes) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, rootdir) == 20 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, options) == 24 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, maxinstances) == 28 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, outsize) == 32 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, insize) == 36 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, timeout) == 40 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, flags) == 48 );
C_ASSERT( sizeof(struct create_named_pipe_request) == 56 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, sharing) == 28 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, maxinstances) == 32 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, outsize) == 36 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, insize) == 40 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, timeout) == 48 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_request, flags) == 56 );
C_ASSERT( sizeof(struct create_named_pipe_request) == 64 );
C_ASSERT( FIELD_OFFSET(struct create_named_pipe_reply, handle) == 8 );
C_ASSERT( sizeof(struct create_named_pipe_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_named_pipe_info_request, handle) == 12 );

View file

@ -2607,6 +2607,7 @@ static void dump_create_named_pipe_request( const struct create_named_pipe_reque
fprintf( stderr, ", attributes=%08x", req->attributes );
fprintf( stderr, ", rootdir=%04x", req->rootdir );
fprintf( stderr, ", options=%08x", req->options );
fprintf( stderr, ", sharing=%08x", req->sharing );
fprintf( stderr, ", maxinstances=%08x", req->maxinstances );
fprintf( stderr, ", outsize=%08x", req->outsize );
fprintf( stderr, ", insize=%08x", req->insize );