Fix NREX in Linux network change notification code
authorMarek Habersack <grendel@twistedcode.net>
Thu, 3 Sep 2015 21:14:46 +0000 (23:14 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Thu, 3 Sep 2015 21:19:22 +0000 (23:19 +0200)
commit4fbe8c8836bc860e4af4a0cf141e301eb4f1dcdc
treee60216e5d37d90798974e1b174a53255f28c93be
parent73e47d3329c530617ae1247cec7e6ee7c878c7a7
Fix NREX in Linux network change notification code

Linux code uses a netlink socket to be notified about network interface
changes. The code is a bit racy and for that reson it can happen that
the LinuxNetworkChange.OnDataAvailable handler is called after the
socket is destroyed (from a timer event) and socket stored in an
instance variable is already null. This is a race most probably
introduced by the new threadpool or TPL code as it started to happen in
several places (mostly BCL tests on Android, but it's *not* specific to
Android).
The workaround here serves as a quick band-aid to be able to move on,
but a more thorough review of the socket code will be required.
mcs/class/System/System.Net.NetworkInformation/NetworkChange.cs