summaryrefslogtreecommitdiff
path: root/scripts/wsrep_sst_rsync.sh
diff options
context:
space:
mode:
authorJan Lindström <jplindst@mariadb.org>2014-04-16 13:08:29 +0300
committerJan Lindström <jplindst@mariadb.org>2014-04-16 13:08:29 +0300
commitfa18dc394406ad684ab2623e7451c9f3ec7adf08 (patch)
tree6b708eaa3b970ee14451c2ffdd5d89c7d8dce0dd /scripts/wsrep_sst_rsync.sh
parent150e88e8c9b85e3e6ce500a91fd215d231e99881 (diff)
downloadmariadb-git-fa18dc394406ad684ab2623e7451c9f3ec7adf08.tar.gz
Merge lp:codership-mysql/5.5 -r3961..3980.
Diffstat (limited to 'scripts/wsrep_sst_rsync.sh')
-rwxr-xr-xscripts/wsrep_sst_rsync.sh31
1 files changed, 17 insertions, 14 deletions
diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh
index 4b78071542c..960eef2df4b 100755
--- a/scripts/wsrep_sst_rsync.sh
+++ b/scripts/wsrep_sst_rsync.sh
@@ -49,19 +49,21 @@ check_pid()
check_pid_and_port()
{
local pid_file=$1
- local rsync_pid=$(cat $pid_file)
- local rsync_port=$2
-
- if [ "$OS" == "Darwin" -o "$OS" == "FreeBSD" ]; then
- # no netstat --program(-p) option in Darwin and FreeBSD
- check_pid $pid_file && \
- lsof -i -Pn 2>/dev/null | \
- grep "(LISTEN)" | grep ":$rsync_port" | grep -w '^rsync[[:space:]]\+'"$rsync_pid" >/dev/null
- else
- check_pid $pid_file && \
- netstat -lnpt 2>/dev/null | \
- grep LISTEN | grep \:$rsync_port | grep $rsync_pid/rsync >/dev/null
+ local rsync_pid=$2
+ local rsync_port=$3
+
+ local port_info=$(lsof -i :$rsync_port -Pn 2>/dev/null | \
+ grep "(LISTEN)")
+ local is_rsync=$(echo $port_info | \
+ grep -w '^rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)
+
+ if [ -n "$port_info" -a -z "$is_rsync" ]; then
+ wsrep_log_error "rsync daemon port '$rsync_port' has been taken"
+ exit 16 # EBUSY
fi
+ check_pid $pid_file && \
+ [ -n "$port_info" ] && [ -n "$is_rsync" ] && \
+ [ $(cat $pid_file) -eq $rsync_pid ]
}
MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_sst_complete"
@@ -234,9 +236,10 @@ EOF
# rm -rf "$DATA"/ib_logfile* # we don't want old logs around
# listen at all interfaces (for firewalled setups)
- rsync --daemon --port $RSYNC_PORT --config "$RSYNC_CONF"
+ rsync --daemon --no-detach --port $RSYNC_PORT --config "$RSYNC_CONF" &
+ RSYNC_REAL_PID=$!
- until check_pid_and_port $RSYNC_PID $RSYNC_PORT
+ until check_pid_and_port $RSYNC_PID $RSYNC_REAL_PID $RSYNC_PORT
do
sleep 0.2
done