Commit e44c0f71 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernel32: Use default buffer size in CreatePipe if 0 was passed.

parent 3d7fabf6
......@@ -1932,6 +1932,8 @@ BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
attr.SecurityQualityOfService = NULL;
if (!size) size = 4096;
timeout.QuadPart = (ULONGLONG)NMPWAIT_USE_DEFAULT_WAIT * -10000;
/* generate a unique pipe name (system wide) */
do
......
......@@ -125,6 +125,20 @@ static void _test_signaled(unsigned line, HANDLE handle)
ok_(__FILE__,line)(res == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", res);
}
#define test_pipe_info(a,b,c,d,e) _test_pipe_info(__LINE__,a,b,c,d,e)
static void _test_pipe_info(unsigned line, HANDLE pipe, DWORD ex_flags, DWORD ex_out_buf_size, DWORD ex_in_buf_size, DWORD ex_max_instances)
{
DWORD flags = 0xdeadbeef, out_buf_size = 0xdeadbeef, in_buf_size = 0xdeadbeef, max_instances = 0xdeadbeef;
BOOL res;
res = GetNamedPipeInfo(pipe, &flags, &out_buf_size, &in_buf_size, &max_instances);
ok_(__FILE__,line)(res, "GetNamedPipeInfo failed: %x\n", res);
ok_(__FILE__,line)(flags == ex_flags, "flags = %x, expected %x\n", flags, ex_flags);
ok_(__FILE__,line)(out_buf_size == ex_out_buf_size, "out_buf_size = %x, expected %u\n", out_buf_size, ex_out_buf_size);
ok_(__FILE__,line)(in_buf_size == ex_in_buf_size, "in_buf_size = %x, expected %u\n", in_buf_size, ex_in_buf_size);
ok_(__FILE__,line)(max_instances == ex_max_instances, "max_instances = %x, expected %u\n", max_instances, ex_max_instances);
}
static void test_CreateNamedPipe(int pipemode)
{
HANDLE hnp;
......@@ -1319,6 +1333,9 @@ static void test_CreatePipe(void)
pipe_attr.bInheritHandle = TRUE;
pipe_attr.lpSecurityDescriptor = NULL;
ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 0) != 0, "CreatePipe failed\n");
test_pipe_info(piperead, FILE_PIPE_SERVER_END, 4096, 4096, 1);
test_pipe_info(pipewrite, 0, 4096, 4096, 1);
ok(WriteFile(pipewrite,PIPENAME,sizeof(PIPENAME), &written, NULL), "Write to anonymous pipe failed\n");
ok(written == sizeof(PIPENAME), "Write to anonymous pipe wrote %d bytes\n", written);
ok(ReadFile(piperead,readbuf,sizeof(readbuf),&read, NULL), "Read from non empty pipe failed\n");
......@@ -1358,6 +1375,12 @@ static void test_CreatePipe(void)
ok(user_apc_ran == FALSE, "user apc ran, pipe using alertable io mode\n");
SleepEx(0, TRUE); /* get rid of apc */
ok(CreatePipe(&piperead, &pipewrite, &pipe_attr, 1) != 0, "CreatePipe failed\n");
test_pipe_info(piperead, FILE_PIPE_SERVER_END, 1, 1, 1);
test_pipe_info(pipewrite, 0, 1, 1, 1);
ok(CloseHandle(pipewrite), "CloseHandle for the Write Pipe failed\n");
ok(CloseHandle(piperead), "CloseHandle for the read pipe failed\n");
}
static void test_CloseHandle(void)
......@@ -2250,20 +2273,6 @@ static void test_NamedPipeHandleState(void)
CloseHandle(server);
}
#define test_pipe_info(a,b,c,d,e) _test_pipe_info(__LINE__,a,b,c,d,e)
static void _test_pipe_info(unsigned line, HANDLE pipe, DWORD ex_flags, DWORD ex_out_buf_size, DWORD ex_in_buf_size, DWORD ex_max_instances)
{
DWORD flags = 0xdeadbeef, out_buf_size = 0xdeadbeef, in_buf_size = 0xdeadbeef, max_instances = 0xdeadbeef;
BOOL res;
res = GetNamedPipeInfo(pipe, &flags, &out_buf_size, &in_buf_size, &max_instances);
ok_(__FILE__,line)(res, "GetNamedPipeInfo failed: %x\n", res);
ok_(__FILE__,line)(flags == ex_flags, "flags = %x, expected %x\n", flags, ex_flags);
ok_(__FILE__,line)(out_buf_size == ex_out_buf_size, "out_buf_size = %x, expected %u\n", out_buf_size, ex_out_buf_size);
ok_(__FILE__,line)(in_buf_size == ex_in_buf_size, "in_buf_size = %x, expected %u\n", in_buf_size, ex_in_buf_size);
ok_(__FILE__,line)(max_instances == ex_max_instances, "max_instances = %x, expected %u\n", max_instances, ex_max_instances);
}
static void test_GetNamedPipeInfo(void)
{
HANDLE server;
......
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