mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
ctdb-scripts: Use more unique temporary file names
Consider this sequence of events: 1. Instance of script running update_tickles() hangs 2. Script debugging is launched asynchronously 3. New instance of script is launched, creates temporary file(s) 4. Original hung script makes progress before asynchronous script debugging kills it, so it removes temporary file(s) 5. New instance of script produces error due to missing files(s) This is obviously rare. Use more unique filenames to avoid step (4) removing the file(s) belonging to other instances of the script. This requires some extra cleanup to avoid too many temporary files (which is why unique filenames were not originally usd). It is sufficient to remove files modified at least 10 minutes ago. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
parent
4afe822397
commit
a7ce00cc03
@ -1082,15 +1082,18 @@ update_tickles ()
|
||||
# IPs as a regexp choice
|
||||
_ipschoice="($(echo $_ips | sed -e 's/ /|/g' -e 's/\./\\\\./g'))"
|
||||
|
||||
# Record connections to our public IPs in a temporary file
|
||||
_my_connections="${tickledir}/${_port}.connections"
|
||||
# Record connections to our public IPs in a temporary file.
|
||||
# This temporary file is in CTDB's private state directory and
|
||||
# $$ is used to avoid a very rare race involving CTDB's script
|
||||
# debugging. No security issue, nothing to see here...
|
||||
_my_connections="${tickledir}/${_port}.connections.$$"
|
||||
netstat -tn |
|
||||
awk -v destpat="^${_ipschoice}:${_port}\$" \
|
||||
'$1 == "tcp" && $6 == "ESTABLISHED" && $4 ~ destpat {print $5, $4}' |
|
||||
sort >"$_my_connections"
|
||||
|
||||
# Record our current tickles in a temporary file
|
||||
_my_tickles="${tickledir}/${_port}.tickles"
|
||||
_my_tickles="${tickledir}/${_port}.tickles.$$"
|
||||
for _i in $_ips ; do
|
||||
ctdb -X gettickles $_i $_port |
|
||||
awk -F'|' 'NR > 1 { printf "%s:%s %s:%s\n", $2, $3, $4, $5 }'
|
||||
@ -1109,7 +1112,10 @@ update_tickles ()
|
||||
ctdb deltickle $_src $_dst
|
||||
done
|
||||
|
||||
rm -f "$_my_connections" "$_my_tickles"
|
||||
rm -f "$_my_connections" "$_my_tickles"
|
||||
|
||||
# Remove stale files from killed scripts
|
||||
find "$tickledir" -type f -mmin +10 | xargs -r rm
|
||||
}
|
||||
|
||||
########################################################
|
||||
|
Loading…
Reference in New Issue
Block a user