Commit 6b71a6d2 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-10383 Named pipes : multiple servers can listen on the same pipename

Use FILE_FLAG_FIRST_PIPE_INSTANCE with the first CreateNamedPipe()
call to make sure the pipe does not already exist.
parent 5fdb3cfc
...@@ -22,3 +22,12 @@ connect(pipe_con,localhost,root,,,,,PIPE); ...@@ -22,3 +22,12 @@ connect(pipe_con,localhost,root,,,,,PIPE);
connection default; connection default;
disconnect pipe_con; disconnect pipe_con;
# MDEV-10383 : check that other server cannot 'bind' on the same pipe
let $MYSQLD_DATADIR= `select @@datadir`;
--error 1
--exec $MYSQLD_CMD --enable-named-pipe --skip-networking --log-error=second-mysqld.err
let SEARCH_FILE=$MYSQLD_DATADIR/second-mysqld.err;
let SEARCH_RANGE= -50;
let SEARCH_PATTERN=\[ERROR\] Create named pipe failed;
source include/search_pattern_in_file.inc;
...@@ -2316,26 +2316,17 @@ static void network_init(void) ...@@ -2316,26 +2316,17 @@ static void network_init(void)
saPipeSecurity.lpSecurityDescriptor = &sdPipeDescriptor; saPipeSecurity.lpSecurityDescriptor = &sdPipeDescriptor;
saPipeSecurity.bInheritHandle = FALSE; saPipeSecurity.bInheritHandle = FALSE;
if ((hPipe= CreateNamedPipe(pipe_name, if ((hPipe= CreateNamedPipe(pipe_name,
PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE,
PIPE_TYPE_BYTE | PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
PIPE_READMODE_BYTE | PIPE_UNLIMITED_INSTANCES,
PIPE_WAIT, (int) global_system_variables.net_buffer_length,
PIPE_UNLIMITED_INSTANCES, (int) global_system_variables.net_buffer_length,
(int) global_system_variables.net_buffer_length, NMPWAIT_USE_DEFAULT_WAIT,
(int) global_system_variables.net_buffer_length, &saPipeSecurity)) == INVALID_HANDLE_VALUE)
NMPWAIT_USE_DEFAULT_WAIT, {
&saPipeSecurity)) == INVALID_HANDLE_VALUE) sql_perror("Create named pipe failed");
{ unireg_abort(1);
LPVOID lpMsgBuf; }
int error=GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf, 0, NULL );
sql_perror((char *)lpMsgBuf);
LocalFree(lpMsgBuf);
unireg_abort(1);
}
} }
#endif #endif
......
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