From 3757a7296c9cd700f9eceb8a9460a2de44e7cc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Fri, 20 Sep 2019 11:21:30 -0400 Subject: [System] Make FileSystemWatcher backend non-static (#16922) * [System] Make FileSystemWatcher backend non-static The FileSystemWatcher `watcher` field is the backend IFileWatcher that's supposed to be used for the actual operations. Each backend has a `bool GetInstance (out watcher)` method that returns a singleton object, so each new instance of FileSystemWatcher gets the same IFileWatcher instance. (They will get different `watcher_handle` instances which are used by some backends to uniquely identify this FileSystemWatcher). However when the first FileSystemWatcher instance is `Dispose`d, it will set `watcher = null` which will prevent the remaining instances from calling watcher?.StopDispatching (watcher_handle); watcher?.Dispose (watcher_handle); which means that the backend won't properly cleanup resources for any other FSW instances that have other `watcher_handle` values. Addresses https://github.com/mono/mono/issues/16709 --- mcs/class/System/System.IO/FileSystemWatcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mcs/class/System/System.IO/FileSystemWatcher.cs') diff --git a/mcs/class/System/System.IO/FileSystemWatcher.cs b/mcs/class/System/System.IO/FileSystemWatcher.cs index 9c003a80e5a..cbf71e7a9a6 100644 --- a/mcs/class/System/System.IO/FileSystemWatcher.cs +++ b/mcs/class/System/System.IO/FileSystemWatcher.cs @@ -61,7 +61,7 @@ namespace System.IO { SearchPattern2 pattern; bool disposed; string mangledFilter; - static IFileWatcher watcher; + IFileWatcher watcher; object watcher_handle; static object lockobj = new object (); -- cgit v1.2.3