Skip to content

Commit 6b71a6d

Browse files
committed
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.
1 parent 5fdb3cf commit 6b71a6d

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

mysql-test/t/named_pipe.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ connect(pipe_con,localhost,root,,,,,PIPE);
2222

2323
connection default;
2424
disconnect pipe_con;
25+
26+
# MDEV-10383 : check that other server cannot 'bind' on the same pipe
27+
let $MYSQLD_DATADIR= `select @@datadir`;
28+
--error 1
29+
--exec $MYSQLD_CMD --enable-named-pipe --skip-networking --log-error=second-mysqld.err
30+
let SEARCH_FILE=$MYSQLD_DATADIR/second-mysqld.err;
31+
let SEARCH_RANGE= -50;
32+
let SEARCH_PATTERN=\[ERROR\] Create named pipe failed;
33+
source include/search_pattern_in_file.inc;

sql/mysqld.cc

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,26 +2316,17 @@ static void network_init(void)
23162316
saPipeSecurity.lpSecurityDescriptor = &sdPipeDescriptor;
23172317
saPipeSecurity.bInheritHandle = FALSE;
23182318
if ((hPipe= CreateNamedPipe(pipe_name,
2319-
PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,
2320-
PIPE_TYPE_BYTE |
2321-
PIPE_READMODE_BYTE |
2322-
PIPE_WAIT,
2323-
PIPE_UNLIMITED_INSTANCES,
2324-
(int) global_system_variables.net_buffer_length,
2325-
(int) global_system_variables.net_buffer_length,
2326-
NMPWAIT_USE_DEFAULT_WAIT,
2327-
&saPipeSecurity)) == INVALID_HANDLE_VALUE)
2328-
{
2329-
LPVOID lpMsgBuf;
2330-
int error=GetLastError();
2331-
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
2332-
FORMAT_MESSAGE_FROM_SYSTEM,
2333-
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
2334-
(LPTSTR) &lpMsgBuf, 0, NULL );
2335-
sql_perror((char *)lpMsgBuf);
2336-
LocalFree(lpMsgBuf);
2337-
unireg_abort(1);
2338-
}
2319+
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE,
2320+
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
2321+
PIPE_UNLIMITED_INSTANCES,
2322+
(int) global_system_variables.net_buffer_length,
2323+
(int) global_system_variables.net_buffer_length,
2324+
NMPWAIT_USE_DEFAULT_WAIT,
2325+
&saPipeSecurity)) == INVALID_HANDLE_VALUE)
2326+
{
2327+
sql_perror("Create named pipe failed");
2328+
unireg_abort(1);
2329+
}
23392330
}
23402331
#endif
23412332

0 commit comments

Comments
 (0)