Skip to content

Commit

Permalink
Loop round iptables commands on EAGAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
bboreham committed Nov 11, 2016
1 parent 959d377 commit 7a86841
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions weave
Expand Up @@ -398,7 +398,13 @@ add_iptables_rule() {
IPTABLES_TABLE="$1"
shift 1
if ! run_iptables -t $IPTABLES_TABLE -C "$@" >/dev/null 2>&1 ; then
run_iptables -t $IPTABLES_TABLE -A "$@" >/dev/null
## Loop until we get an exit code other than "temporarily unavailable"
while true ; do
run_iptables -t $IPTABLES_TABLE -A "$@" >/dev/null && return 0
if [ $? != 4 ] ; then
return 1
fi
done
fi
}

Expand All @@ -407,7 +413,13 @@ insert_iptables_rule() {
IPTABLES_TABLE="$1"
shift 1
if ! run_iptables -t $IPTABLES_TABLE -C "$@" >/dev/null 2>&1 ; then
run_iptables -t $IPTABLES_TABLE -I "$@" >/dev/null
## Loop until we get an exit code other than "temporarily unavailable"
while true ; do
run_iptables -t $IPTABLES_TABLE -I "$@" >/dev/null && return 0
if [ $? != 4 ] ; then
return 1
fi
done
fi
}

Expand Down

0 comments on commit 7a86841

Please sign in to comment.