1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/libnetwork/iptables
Max Timchenko fc2414f988 Ensure iptables initialization only happens once
I saw a rare race during the first few calls to iptables module
where some of them would reenter initCheck() after the first call
to it already changed iptablesPath, but before the rest of the function
completed (in particular the long execs into testing for availability
of --wait flag and determining iptables version), resulting in
failure of one or more of iptables calls that did not use --wait and
were concurrent.

To fix the problem, this change gathers all one-time initialization into a
single function under a sync.Once instead of using a global variable
as a "done initializing" flag before initialization is done. sync.Once
guarantees all concurrent calls will block until the first one completes.

In addition, it turns out that GetVersion(), called from initCheck(), used
Raw() which called back into initCheck() via raw(), which did not cause a
problem in the earlier implementation but deadlocked when initialization became
strict.  This was changed to use a direct call, similar to initialization of
supportsXlock.

Signed-off-by: Max Timchenko <max@maxvt.com>
2017-03-08 20:37:13 +02:00
..
firewalld.go Close dbus connection if firewalld is not started 2016-03-09 09:31:22 -08:00
firewalld_test.go Remove unnecessary string formats 2016-11-22 09:29:53 +08:00
iptables.go Ensure iptables initialization only happens once 2017-03-08 20:37:13 +02:00
iptables_test.go Remove unnecessary string formats 2016-11-22 09:29:53 +08:00