Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
fa5f18d6
Commit
fa5f18d6
authored
Sep 09, 2015
by
Nirbhay Choubey
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '5.5-galera' into 10.0-galera
parents
f533b2b4
37ae601a
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
497 additions
and
244 deletions
+497
-244
cmake/wsrep.cmake
cmake/wsrep.cmake
+3
-3
scripts/wsrep_sst_common.sh
scripts/wsrep_sst_common.sh
+28
-11
scripts/wsrep_sst_mysqldump.sh
scripts/wsrep_sst_mysqldump.sh
+19
-15
scripts/wsrep_sst_rsync.sh
scripts/wsrep_sst_rsync.sh
+1
-1
scripts/wsrep_sst_xtrabackup-v2.sh
scripts/wsrep_sst_xtrabackup-v2.sh
+187
-111
scripts/wsrep_sst_xtrabackup.sh
scripts/wsrep_sst_xtrabackup.sh
+12
-8
sql/wsrep_mysqld.cc
sql/wsrep_mysqld.cc
+4
-13
sql/wsrep_notify.cc
sql/wsrep_notify.cc
+1
-1
sql/wsrep_sst.cc
sql/wsrep_sst.cc
+128
-76
sql/wsrep_utils.cc
sql/wsrep_utils.cc
+90
-3
sql/wsrep_utils.h
sql/wsrep_utils.h
+24
-2
No files found.
cmake/wsrep.cmake
View file @
fa5f18d6
...
@@ -18,12 +18,12 @@
...
@@ -18,12 +18,12 @@
# so WSREP_VERSION is produced regardless
# so WSREP_VERSION is produced regardless
# Set the patch version
# Set the patch version
SET
(
WSREP_PATCH_VERSION
"1
0
"
)
SET
(
WSREP_PATCH_VERSION
"1
2
"
)
# MariaDB addition: Revision number of the last revision merged from
# MariaDB addition: Revision number of the last revision merged from
# codership branch visible in @@visible_comment.
# codership branch visible in @@visible_comment.
# Branch :
codership-mysql/5.6
# Branch :
https://github.com/codership/mysql-wsrep/tree/5.5
SET
(
WSREP_PATCH_REVNO
"4
144"
)
# Should be updated on every merge.
SET
(
WSREP_PATCH_REVNO
"4
f81026"
)
# Should be updated on every merge.
# MariaDB: Obtain patch revision number:
# MariaDB: Obtain patch revision number:
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.
...
...
scripts/wsrep_sst_common.sh
View file @
fa5f18d6
# Copyright (C) 2012-201
4
Codership Oy
# Copyright (C) 2012-201
5
Codership Oy
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -20,8 +20,11 @@ set -u
...
@@ -20,8 +20,11 @@ set -u
WSREP_SST_OPT_BYPASS
=
0
WSREP_SST_OPT_BYPASS
=
0
WSREP_SST_OPT_BINLOG
=
""
WSREP_SST_OPT_BINLOG
=
""
WSREP_SST_OPT_CONF_SUFFIX
=
""
WSREP_SST_OPT_DATA
=
""
WSREP_SST_OPT_DATA
=
""
WSREP_SST_OPT_AUTH
=
""
WSREP_SST_OPT_AUTH
=
${
WSREP_SST_OPT_AUTH
:-}
WSREP_SST_OPT_USER
=
${
WSREP_SST_OPT_USER
:-}
WSREP_SST_OPT_PSWD
=
${
WSREP_SST_OPT_PSWD
:-}
while
[
$#
-gt
0
]
;
do
while
[
$#
-gt
0
]
;
do
case
"
$1
"
in
case
"
$1
"
in
...
@@ -29,10 +32,6 @@ case "$1" in
...
@@ -29,10 +32,6 @@ case "$1" in
readonly
WSREP_SST_OPT_ADDR
=
"
$2
"
readonly
WSREP_SST_OPT_ADDR
=
"
$2
"
shift
shift
;;
;;
'--auth'
)
WSREP_SST_OPT_AUTH
=
"
$2
"
shift
;;
'--bypass'
)
'--bypass'
)
WSREP_SST_OPT_BYPASS
=
1
WSREP_SST_OPT_BYPASS
=
1
;;
;;
...
@@ -45,7 +44,7 @@ case "$1" in
...
@@ -45,7 +44,7 @@ case "$1" in
shift
shift
;;
;;
'--defaults-group-suffix'
)
'--defaults-group-suffix'
)
readonly
WSREP_SST_OPT_CONF_SUFFIX
=
"
$2
"
WSREP_SST_OPT_CONF_SUFFIX
=
"
$2
"
shift
shift
;;
;;
'--host'
)
'--host'
)
...
@@ -97,6 +96,7 @@ shift
...
@@ -97,6 +96,7 @@ shift
done
done
readonly
WSREP_SST_OPT_BYPASS
readonly
WSREP_SST_OPT_BYPASS
readonly
WSREP_SST_OPT_BINLOG
readonly
WSREP_SST_OPT_BINLOG
readonly
WSREP_SST_OPT_CONF_SUFFIX
# try to use my_print_defaults, mysql and mysqldump that come with the sources
# try to use my_print_defaults, mysql and mysqldump that come with the sources
# (for MTR suite)
# (for MTR suite)
...
@@ -124,12 +124,30 @@ else
...
@@ -124,12 +124,30 @@ else
MY_PRINT_DEFAULTS
=
$(
which my_print_defaults
)
MY_PRINT_DEFAULTS
=
$(
which my_print_defaults
)
fi
fi
wsrep_auth_not_set
()
{
[
-z
"
$WSREP_SST_OPT_AUTH
"
-o
"
$WSREP_SST_OPT_AUTH
"
=
"(null)"
]
}
# For Bug:1200727
# For Bug:1200727
if
$MY_PRINT_DEFAULTS
-c
$WSREP_SST_OPT_CONF
sst |
grep
-q
"wsrep_sst_auth"
;
then
if
$MY_PRINT_DEFAULTS
-c
$WSREP_SST_OPT_CONF
sst |
grep
-q
"wsrep_sst_auth"
if
[
-z
"
$WSREP_SST_OPT_AUTH
"
-o
"
$WSREP_SST_OPT_AUTH
"
=
"(null)"
]
;
then
then
WSREP_SST_OPT_AUTH
=
$(
my_print_defaults
-c
$WSREP_SST_OPT_CONF
sst |
grep
--
"--wsrep_sst_auth"
|
cut
-d
=
-f2
)
if
wsrep_auth_not_set
then
WSREP_SST_OPT_AUTH
=
$(
MY_PRINT_DEFAULTS
-c
$WSREP_SST_OPT_CONF
sst |
grep
--
"--wsrep_sst_auth"
|
cut
-d
=
-f2
)
fi
fi
fi
fi
readonly
WSREP_SST_OPT_AUTH
# Splitting AUTH into potential user:password pair
if
!
wsrep_auth_not_set
then
readonly
AUTH_VEC
=(
${
WSREP_SST_OPT_AUTH
//
:/
}
)
WSREP_SST_OPT_USER
=
"
${
AUTH_VEC
[0]
:-}
"
WSREP_SST_OPT_PSWD
=
"
${
AUTH_VEC
[1]
:-}
"
fi
readonly
WSREP_SST_OPT_USER
readonly
WSREP_SST_OPT_PSWD
if
[
-n
"
${
WSREP_SST_OPT_DATA
:-}
"
]
if
[
-n
"
${
WSREP_SST_OPT_DATA
:-}
"
]
then
then
...
@@ -138,7 +156,6 @@ else
...
@@ -138,7 +156,6 @@ else
SST_PROGRESS_FILE
=
""
SST_PROGRESS_FILE
=
""
fi
fi
wsrep_log
()
wsrep_log
()
{
{
# echo everything to stderr so that it gets into common error log
# echo everything to stderr so that it gets into common error log
...
...
scripts/wsrep_sst_mysqldump.sh
View file @
fa5f18d6
#!/bin/bash -e
#!/bin/bash -
u
e
# Copyright (C) 2009 Codership Oy
# Copyright (C) 2009
-2015
Codership Oy
#
#
# This program is free software; you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -41,7 +41,6 @@ local_ip()
...
@@ -41,7 +41,6 @@ local_ip()
return
1
return
1
}
}
if
test
-z
"
$WSREP_SST_OPT_USER
"
;
then
wsrep_log_error
"USER cannot be nil"
;
exit
$EINVAL
;
fi
if
test
-z
"
$WSREP_SST_OPT_HOST
"
;
then
wsrep_log_error
"HOST cannot be nil"
;
exit
$EINVAL
;
fi
if
test
-z
"
$WSREP_SST_OPT_HOST
"
;
then
wsrep_log_error
"HOST cannot be nil"
;
exit
$EINVAL
;
fi
if
test
-z
"
$WSREP_SST_OPT_PORT
"
;
then
wsrep_log_error
"PORT cannot be nil"
;
exit
$EINVAL
;
fi
if
test
-z
"
$WSREP_SST_OPT_PORT
"
;
then
wsrep_log_error
"PORT cannot be nil"
;
exit
$EINVAL
;
fi
if
test
-z
"
$WSREP_SST_OPT_LPORT
"
;
then
wsrep_log_error
"LPORT cannot be nil"
;
exit
$EINVAL
;
fi
if
test
-z
"
$WSREP_SST_OPT_LPORT
"
;
then
wsrep_log_error
"LPORT cannot be nil"
;
exit
$EINVAL
;
fi
...
@@ -64,13 +63,18 @@ then
...
@@ -64,13 +63,18 @@ then
exit
$EINVAL
exit
$EINVAL
fi
fi
# For Bug:1293798
[
-n
"
$WSREP_SST_OPT_USER
"
]
&&
AUTH
=
"-u
$WSREP_SST_OPT_USER
"
||
AUTH
=
if
[
-z
"
$WSREP_SST_OPT_PSWD
"
-a
-n
"
$WSREP_SST_OPT_AUTH
"
]
;
then
WSREP_SST_OPT_USER
=
$(
echo
$WSREP_SST_OPT_AUTH
|
cut
-d
:
-f1
)
# Refs https://github.com/codership/mysql-wsrep/issues/141
WSREP_SST_OPT_PSWD
=
$(
echo
$WSREP_SST_OPT_AUTH
|
cut
-d
:
-f2
)
# Passing password in MYSQL_PWD environment variable is considered
fi
# "extremely insecure" by MySQL Guidelines for Password Security
AUTH
=
"-u
$WSREP_SST_OPT_USER
"
# (https://dev.mysql.com/doc/refman/5.6/en/password-security-user.html)
if
test
-n
"
$WSREP_SST_OPT_PSWD
"
;
then
AUTH
=
"
$AUTH
-p
$WSREP_SST_OPT_PSWD
"
;
fi
# that is even less secure than passing it on a command line! It is doubtful:
# the whole command line is easily observable by any unprivileged user via ps,
# whereas (at least on Linux) unprivileged user can't see process environment
# that he does not own. So while it may be not secure in the NSA sense of the
# word, it is arguably more secure than passing password on the command line.
[
-n
"
$WSREP_SST_OPT_PSWD
"
]
&&
export
MYSQL_PWD
=
"
$WSREP_SST_OPT_PSWD
"
STOP_WSREP
=
"SET wsrep_on=OFF;"
STOP_WSREP
=
"SET wsrep_on=OFF;"
...
@@ -136,15 +140,15 @@ fi
...
@@ -136,15 +140,15 @@ fi
MYSQLDUMP
=
"
$MYSQLDUMP
$AUTH
-S
$WSREP_SST_OPT_SOCKET
\
MYSQLDUMP
=
"
$MYSQLDUMP
$AUTH
-S
$WSREP_SST_OPT_SOCKET
\
--add-drop-database --add-drop-table --skip-add-locks --create-options
\
--add-drop-database --add-drop-table --skip-add-locks --create-options
\
--disable-keys --extended-insert --skip-lock-tables --quick --set-charset
\
--disable-keys --extended-insert --skip-lock-tables --quick --set-charset
\
--skip-comments --flush-privileges --all-databases"
--skip-comments --flush-privileges --all-databases
--events
"
# need to disable logging when loading the dump
# need to disable logging when loading the dump
# reason is that dump contains ALTER TABLE for log tables, and
# reason is that dump contains ALTER TABLE for log tables, and
# this causes an error if logging is enabled
# this causes an error if logging is enabled
GENERAL_LOG_OPT
=
`
$MYSQL
--skip-column-names
-e
"
$STOP_WSREP
SELECT @@GENERAL_LOG"
`
GENERAL_LOG_OPT
=
`
$MYSQL
--skip-column-names
-e
"
$STOP_WSREP
SELECT @@GENERAL_LOG"
`
SLOW_LOG_OPT
=
`
$MYSQL
--skip-column-names
-e
"
$STOP_WSREP
SELECT @@SLOW_QUERY_LOG"
`
SLOW_LOG_OPT
=
`
$MYSQL
--skip-column-names
-e
"
$STOP_WSREP
SELECT @@SLOW_QUERY_LOG"
`
$MYSQL
-e
"
$STOP_WSREP
SET GLOBAL GENERAL_LOG=OFF"
$MYSQL
-e
"
$STOP_WSREP
SET GLOBAL GENERAL_LOG=OFF"
$MYSQL
-e
"
$STOP_WSREP
SET GLOBAL SLOW_QUERY_LOG=OFF"
$MYSQL
-e
"
$STOP_WSREP
SET GLOBAL SLOW_QUERY_LOG=OFF"
# commands to restore log settings
# commands to restore log settings
RESTORE_GENERAL_LOG
=
"SET GLOBAL GENERAL_LOG=
$GENERAL_LOG_OPT
;"
RESTORE_GENERAL_LOG
=
"SET GLOBAL GENERAL_LOG=
$GENERAL_LOG_OPT
;"
...
...
scripts/wsrep_sst_rsync.sh
View file @
fa5f18d6
...
@@ -32,8 +32,8 @@ wsrep_check_programs rsync
...
@@ -32,8 +32,8 @@ wsrep_check_programs rsync
cleanup_joiner
()
cleanup_joiner
()
{
{
wsrep_log_info
"Joiner cleanup."
local
PID
=
$(
cat
"
$RSYNC_PID
"
2>/dev/null
||
echo
0
)
local
PID
=
$(
cat
"
$RSYNC_PID
"
2>/dev/null
||
echo
0
)
wsrep_log_info
"Joiner cleanup. rsync PID:
$PID
"
[
"0"
!=
"
$PID
"
]
&&
kill
$PID
&&
sleep
0.5
&&
kill
-9
$PID
>
/dev/null 2>&1
\
[
"0"
!=
"
$PID
"
]
&&
kill
$PID
&&
sleep
0.5
&&
kill
-9
$PID
>
/dev/null 2>&1
\
||
:
||
:
rm
-rf
"
$RSYNC_CONF
"
rm
-rf
"
$RSYNC_CONF
"
...
...
scripts/wsrep_sst_xtrabackup-v2.sh
View file @
fa5f18d6
This diff is collapsed.
Click to expand it.
scripts/wsrep_sst_xtrabackup.sh
View file @
fa5f18d6
...
@@ -61,7 +61,6 @@ pcmd="pv $pvopts"
...
@@ -61,7 +61,6 @@ pcmd="pv $pvopts"
declare
-a
RC
declare
-a
RC
INNOBACKUPEX_BIN
=
innobackupex
INNOBACKUPEX_BIN
=
innobackupex
readonly
AUTH
=(
${
WSREP_SST_OPT_AUTH
//
:/
}
)
DATA
=
"
${
WSREP_SST_OPT_DATA
}
"
DATA
=
"
${
WSREP_SST_OPT_DATA
}
"
INFO_FILE
=
"xtrabackup_galera_info"
INFO_FILE
=
"xtrabackup_galera_info"
IST_FILE
=
"xtrabackup_ist"
IST_FILE
=
"xtrabackup_ist"
...
@@ -150,7 +149,11 @@ get_transfer()
...
@@ -150,7 +149,11 @@ get_transfer()
fi
fi
wsrep_log_info
"Using netcat as streamer"
wsrep_log_info
"Using netcat as streamer"
if
[[
"
$WSREP_SST_OPT_ROLE
"
==
"joiner"
]]
;
then
if
[[
"
$WSREP_SST_OPT_ROLE
"
==
"joiner"
]]
;
then
if
nc
-h
|
grep
-q
ncat
;
then
tcmd
=
"nc -l
${
TSST_PORT
}
"
else
tcmd
=
"nc -dl
${
TSST_PORT
}
"
tcmd
=
"nc -dl
${
TSST_PORT
}
"
fi
else
else
tcmd
=
"nc
${
REMOTEIP
}
${
TSST_PORT
}
"
tcmd
=
"nc
${
REMOTEIP
}
${
TSST_PORT
}
"
fi
fi
...
@@ -435,13 +438,14 @@ then
...
@@ -435,13 +438,14 @@ then
then
then
TMPDIR
=
"
${
TMPDIR
:-
/tmp
}
"
TMPDIR
=
"
${
TMPDIR
:-
/tmp
}
"
if
[
"
$
{
AUTH
[0]
}
"
!=
"(null)"
]
;
then
if
[
"
$
WSREP_SST_OPT_USER
"
!=
"(null)"
]
;
then
INNOEXTRA+
=
" --user=
$
{
AUTH
[0]
}
"
INNOEXTRA+
=
" --user=
$
WSREP_SST_OPT_USER
"
fi
fi
if
[
${#
AUTH
[*]
}
-eq
2
]
;
then
if
[
-n
"
$WSREP_SST_OPT_PSWD
"
]
;
then
INNOEXTRA+
=
" --password=
${
AUTH
[1]
}
"
# INNOEXTRA+=" --password=$WSREP_SST_OPT_PSWD"
elif
[
"
${
AUTH
[0]
}
"
!=
"(null)"
]
;
then
export
MYSQL_PWD
=
"
$WSREP_SST_OPT_PSWD
"
else
# Empty password, used for testing, debugging etc.
# Empty password, used for testing, debugging etc.
INNOEXTRA+
=
" --password="
INNOEXTRA+
=
" --password="
fi
fi
...
...
sql/wsrep_mysqld.cc
View file @
fa5f18d6
...
@@ -777,19 +777,10 @@ bool wsrep_start_replication()
...
@@ -777,19 +777,10 @@ bool wsrep_start_replication()
wsrep_sst_donor
,
wsrep_sst_donor
,
bootstrap
)))
bootstrap
)))
{
{
if
(
-
ESOCKTNOSUPPORT
==
rcode
)
DBUG_PRINT
(
"wsrep"
,(
"wsrep->connect(%s) failed: %d"
,
{
DBUG_PRINT
(
"wsrep"
,(
"unrecognized cluster address: '%s', rcode: %d"
,
wsrep_cluster_address
,
rcode
));
wsrep_cluster_address
,
rcode
));
WSREP_ERROR
(
"unrecognized cluster address: '%s', rcode
: %d"
,
WSREP_ERROR
(
"wsrep::connect(%s) failed
: %d"
,
wsrep_cluster_address
,
rcode
);
wsrep_cluster_address
,
rcode
);
}
else
{
DBUG_PRINT
(
"wsrep"
,(
"wsrep->connect() failed: %d"
,
rcode
));
WSREP_ERROR
(
"wsrep::connect() failed: %d"
,
rcode
);
}
return
false
;
return
false
;
}
}
else
else
...
...
sql/wsrep_notify.cc
View file @
fa5f18d6
...
@@ -97,7 +97,7 @@ void wsrep_notify_status (wsrep_member_status_t status,
...
@@ -97,7 +97,7 @@ void wsrep_notify_status (wsrep_member_status_t status,
return
;
return
;
}
}
wsp
::
process
p
(
cmd_ptr
,
"r"
);
wsp
::
process
p
(
cmd_ptr
,
"r"
,
NULL
);
p
.
wait
();
p
.
wait
();
int
err
=
p
.
error
();
int
err
=
p
.
error
();
...
...
sql/wsrep_sst.cc
View file @
fa5f18d6
This diff is collapsed.
Click to expand it.
sql/wsrep_utils.cc
View file @
fa5f18d6
...
@@ -63,7 +63,7 @@ wsrep_prepend_PATH (const char* path)
...
@@ -63,7 +63,7 @@ wsrep_prepend_PATH (const char* path)
size_t
const
new_path_len
(
strlen
(
old_path
)
+
strlen
(
":"
)
+
size_t
const
new_path_len
(
strlen
(
old_path
)
+
strlen
(
":"
)
+
strlen
(
path
)
+
1
);
strlen
(
path
)
+
1
);
char
*
const
new_path
(
reinterpret
_cast
<
char
*>
(
malloc
(
new_path_len
)));
char
*
const
new_path
(
static
_cast
<
char
*>
(
malloc
(
new_path_len
)));
if
(
new_path
)
if
(
new_path
)
{
{
...
@@ -89,6 +89,90 @@ wsrep_prepend_PATH (const char* path)
...
@@ -89,6 +89,90 @@ wsrep_prepend_PATH (const char* path)
namespace
wsp
namespace
wsp
{
{
bool
env
::
ctor_common
(
char
**
e
)
{
env_
=
static_cast
<
char
**>
(
malloc
((
len_
+
1
)
*
sizeof
(
char
*
)));
if
(
env_
)
{
for
(
size_t
i
(
0
);
i
<
len_
;
++
i
)
{
assert
(
e
[
i
]);
// caller should make sure about len_
env_
[
i
]
=
strdup
(
e
[
i
]);
if
(
!
env_
[
i
])
{
errno_
=
errno
;
WSREP_ERROR
(
"Failed to allocate env. var: %s"
,
e
[
i
]);
return
true
;
}
}
env_
[
len_
]
=
NULL
;
return
false
;
}
else
{
errno_
=
errno
;
WSREP_ERROR
(
"Failed to allocate env. var vector of length: %zu"
,
len_
);
return
true
;
}
}
void
env
::
dtor
()
{
if
(
env_
)
{
/* don't need to go beyond the first NULL */
for
(
size_t
i
(
0
);
env_
[
i
]
!=
NULL
;
++
i
)
{
free
(
env_
[
i
]);
}
free
(
env_
);
env_
=
NULL
;
}
len_
=
0
;
}
env
::
env
(
char
**
e
)
:
len_
(
0
),
env_
(
NULL
),
errno_
(
0
)
{
if
(
!
e
)
{
e
=
environ
;
}
/* count the size of the vector */
while
(
e
[
len_
])
{
++
len_
;
}
if
(
ctor_common
(
e
))
dtor
();
}
env
::
env
(
const
env
&
e
)
:
len_
(
e
.
len_
),
env_
(
0
),
errno_
(
0
)
{
if
(
ctor_common
(
e
.
env_
))
dtor
();
}
env
::~
env
()
{
dtor
();
}
int
env
::
append
(
const
char
*
val
)
{
char
**
tmp
=
static_cast
<
char
**>
(
realloc
(
env_
,
(
len_
+
2
)
*
sizeof
(
char
*
)));
if
(
tmp
)
{
env_
=
tmp
;
env_
[
len_
]
=
strdup
(
val
);
if
(
env_
[
len_
])
{
++
len_
;
env_
[
len_
]
=
NULL
;
}
else
errno_
=
errno
;
}
else
errno_
=
errno
;
return
errno_
;
}
#define PIPE_READ 0
#define PIPE_READ 0
#define PIPE_WRITE 1
#define PIPE_WRITE 1
#define STDIN_FD 0
#define STDIN_FD 0
...
@@ -98,7 +182,7 @@ namespace wsp
...
@@ -98,7 +182,7 @@ namespace wsp
# define POSIX_SPAWN_USEVFORK 0
# define POSIX_SPAWN_USEVFORK 0
#endif
#endif
process
::
process
(
const
char
*
cmd
,
const
char
*
type
)
process
::
process
(
const
char
*
cmd
,
const
char
*
type
,
char
**
env
)
:
str_
(
cmd
?
strdup
(
cmd
)
:
strdup
(
""
)),
io_
(
NULL
),
err_
(
EINVAL
),
pid_
(
0
)
:
str_
(
cmd
?
strdup
(
cmd
)
:
strdup
(
""
)),
io_
(
NULL
),
err_
(
EINVAL
),
pid_
(
0
)
{
{
if
(
0
==
str_
)
if
(
0
==
str_
)
...
@@ -120,6 +204,8 @@ process::process (const char* cmd, const char* type)
...
@@ -120,6 +204,8 @@ process::process (const char* cmd, const char* type)
return
;
return
;
}
}
if
(
NULL
==
env
)
{
env
=
environ
;
}
// default to global environment
int
pipe_fds
[
2
]
=
{
-
1
,
};
int
pipe_fds
[
2
]
=
{
-
1
,
};
if
(
::
pipe
(
pipe_fds
))
if
(
::
pipe
(
pipe_fds
))
{
{
...
@@ -215,7 +301,7 @@ process::process (const char* cmd, const char* type)
...
@@ -215,7 +301,7 @@ process::process (const char* cmd, const char* type)
goto
cleanup_fact
;
goto
cleanup_fact
;
}
}
err_
=
posix_spawnp
(
&
pid_
,
pargv
[
0
],
&
fact
,
&
attr
,
pargv
,
env
iron
);
err_
=
posix_spawnp
(
&
pid_
,
pargv
[
0
],
&
fact
,
&
attr
,
pargv
,
env
);
if
(
err_
)
if
(
err_
)
{
{
WSREP_ERROR
(
"posix_spawnp(%s) failed: %d (%s)"
,
WSREP_ERROR
(
"posix_spawnp(%s) failed: %d (%s)"
,
...
@@ -309,6 +395,7 @@ process::wait ()
...
@@ -309,6 +395,7 @@ process::wait ()
{
{
case
126
:
err_
=
EACCES
;
break
;
/* Permission denied */
case
126
:
err_
=
EACCES
;
break
;
/* Permission denied */
case
127
:
err_
=
ENOENT
;
break
;
/* No such file or directory */
case
127
:
err_
=
ENOENT
;
break
;
/* No such file or directory */
case
143
:
err_
=
EINTR
;
break
;
/* Subprocess killed */
}
}
WSREP_ERROR
(
"Process completed with error: %s: %d (%s)"
,
WSREP_ERROR
(
"Process completed with error: %s: %d (%s)"
,
str_
,
err_
,
strerror
(
err_
));
str_
,
err_
,
strerror
(
err_
));
...
...
sql/wsrep_utils.h
View file @
fa5f18d6
/* Copyright (C) 2013 Codership Oy <info@codership.com>
/* Copyright (C) 2013
-2015
Codership Oy <info@codership.com>
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
...
@@ -44,6 +44,25 @@ class node_status
...
@@ -44,6 +44,25 @@ class node_status
extern
wsp
::
node_status
local_status
;
extern
wsp
::
node_status
local_status
;
namespace
wsp
{
namespace
wsp
{
/* a class to manage env vars array */
class
env
{
private:
size_t
len_
;
char
**
env_
;
int
errno_
;
bool
ctor_common
(
char
**
e
);
void
dtor
();
env
&
operator
=
(
env
);
public:
explicit
env
(
char
**
env
);
explicit
env
(
const
env
&
);
~
env
();
int
append
(
const
char
*
var
);
/* add a new env. var */
int
error
()
const
{
return
errno_
;
}
char
**
operator
()()
{
return
env_
;
}
};
/* A small class to run external programs. */
/* A small class to run external programs. */
class
process
class
process
{
{
...
@@ -56,8 +75,9 @@ class process
...
@@ -56,8 +75,9 @@ class process
public:
public:
/*! @arg type is a pointer to a null-terminated string which must contain
/*! @arg type is a pointer to a null-terminated string which must contain
either the letter 'r' for reading or the letter 'w' for writing.
either the letter 'r' for reading or the letter 'w' for writing.
@arg env optional null-terminated vector of environment variables
*/
*/
process
(
const
char
*
cmd
,
const
char
*
type
);
process
(
const
char
*
cmd
,
const
char
*
type
,
char
**
env
);
~
process
();
~
process
();
FILE
*
pipe
()
{
return
io_
;
}
FILE
*
pipe
()
{
return
io_
;
}
...
@@ -90,6 +110,8 @@ class string
...
@@ -90,6 +110,8 @@ class string
{
{
public:
public:
string
()
:
string_
(
0
)
{}
string
()
:
string_
(
0
)
{}
explicit
string
(
size_t
s
)
:
string_
(
static_cast
<
char
*>
(
malloc
(
s
)))
{}
char
*
operator
()()
{
return
string_
;
}
void
set
(
char
*
str
)
{
if
(
string_
)
free
(
string_
);
string_
=
str
;
}
void
set
(
char
*
str
)
{
if
(
string_
)
free
(
string_
);
string_
=
str
;
}
~
string
()
{
set
(
0
);
}
~
string
()
{
set
(
0
);
}
private:
private:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment