summaryrefslogtreecommitdiffhomepage
path: root/windows
diff options
context:
space:
mode:
Diffstat (limited to 'windows')
-rw-r--r--windows/winnet/src/winnet/networkadaptermonitor.cpp10
-rw-r--r--windows/winnet/src/winnet/networkadaptermonitor.h4
2 files changed, 13 insertions, 1 deletions
diff --git a/windows/winnet/src/winnet/networkadaptermonitor.cpp b/windows/winnet/src/winnet/networkadaptermonitor.cpp
index 92eab84932..2cbffd1198 100644
--- a/windows/winnet/src/winnet/networkadaptermonitor.cpp
+++ b/windows/winnet/src/winnet/networkadaptermonitor.cpp
@@ -276,6 +276,16 @@ void __stdcall NetworkAdapterMonitor::Callback(void *context, MIB_IPINTERFACE_RO
{
auto inst = reinterpret_cast<NetworkAdapterMonitor *>(context);
+ //
+ // Calls into this function are supposed to be serialized by Windows.
+ // That's not true on Windows 10 :-(
+ //
+ // This can be easily reproduced by changing the callback to never return,
+ // and observing more events being delivered.
+ //
+
+ std::scoped_lock<std::mutex> lock(inst->m_callbackLock);
+
try
{
inst->callback(hint, updateType);
diff --git a/windows/winnet/src/winnet/networkadaptermonitor.h b/windows/winnet/src/winnet/networkadaptermonitor.h
index fe78bb7e2d..044fa62d54 100644
--- a/windows/winnet/src/winnet/networkadaptermonitor.h
+++ b/windows/winnet/src/winnet/networkadaptermonitor.h
@@ -9,7 +9,7 @@
#include <windows.h>
#include <functional>
#include <vector>
-
+#include <mutex>
class NetworkAdapterMonitor
{
@@ -59,6 +59,8 @@ private:
std::shared_ptr<IDataProvider> m_dataProvider;
+ std::mutex m_callbackLock;
+
MIB_IF_ROW2 getAdapter(NET_LUID luid) const;
bool hasIPv4Interface(NET_LUID luid) const;