summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2018-09-10 10:04:42 +0200
committerOdd Stranne <odd@mullvad.net>2018-09-12 13:20:20 +0200
commit3c82d1f23f2b52559e0894a4203bcdfa0734c494 (patch)
treebd4999fcb029552ba9066e3a9b30905c249eb216
parentd54fdd286d09eaf4b6bd0b6958bae7b591f19cc5 (diff)
downloadmullvadvpn-3c82d1f23f2b52559e0894a4203bcdfa0734c494.tar.xz
mullvadvpn-3c82d1f23f2b52559e0894a4203bcdfa0734c494.zip
Try to reset all adapters even if one or more adapters fail to reset
-rw-r--r--windows/windns/src/windns/windnscontext.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/windows/windns/src/windns/windnscontext.cpp b/windows/windns/src/windns/windnscontext.cpp
index 0dfdaf2359..29cb034566 100644
--- a/windows/windns/src/windns/windnscontext.cpp
+++ b/windows/windns/src/windns/windnscontext.cpp
@@ -3,6 +3,8 @@
#include "libcommon/wmi/connection.h"
#include "netconfigeventsink.h"
#include "netconfighelpers.h"
+#include "confineoperation.h"
+#include <functional>
using namespace common;
@@ -78,15 +80,36 @@ void WinDnsContext::reset()
m_notification = nullptr;
//
- // Revert configs
- // Safe to do without a mutex guarding the config manager
+ // Reset adapter configs.
//
+ // Safe to do without a mutex guarding the config manager.
+ //
+ // Try to reset as many adapters as possible, even if one or more fails to reset.
+ //
+
+ bool success = true;
- m_configManager->processConfigs([&](const InterfaceConfig &config)
+ auto forwardError = std::bind(&WinDnsContext::error, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
+
+ m_configManager->processConfigs([&success, &forwardError](const InterfaceConfig &config)
{
- nchelpers::RevertDnsServers(config);
+ const auto adapterStatus = ConfineOperation("Reset adapter DNS configuration", forwardError, [&config]()
+ {
+ nchelpers::RevertDnsServers(config);
+ });
+
+ if (false == adapterStatus)
+ {
+ success = false;
+ }
+
return true;
});
+
+ if (false == success)
+ {
+ throw std::runtime_error("Resetting DNS failed for one or more adapters");
+ }
}
// IClientSinkProxy