locking fixes
[mono.git] / mcs / class / System / System.IO / KeventWatcher.cs
index 803629effcdc3f7e2f31c405466e92e896687d7c..d26c30e22f7935e391891119397ce1a9449770fb 100644 (file)
@@ -93,32 +93,31 @@ namespace System.IO {
                {
                }
                
+               // Locked by caller
                public static bool GetInstance (out IFileWatcher watcher)
                {
-                       lock (typeof (KeventWatcher)) {
-                               if (failed == true) {
-                                       watcher = null;
-                                       return false;
-                               }
-
-                               if (instance != null) {
-                                       watcher = instance;
-                                       return true;
-                               }
-
-                               watches = Hashtable.Synchronized (new Hashtable ());
-                               requests = Hashtable.Synchronized (new Hashtable ());
-                               conn = kqueue();
-                               if (conn == -1) {
-                                       failed = true;
-                                       watcher = null;
-                                       return false;
-                               }
+                       if (failed == true) {
+                               watcher = null;
+                               return false;
+                       }
 
-                               instance = new KeventWatcher ();
+                       if (instance != null) {
                                watcher = instance;
                                return true;
                        }
+
+                       watches = Hashtable.Synchronized (new Hashtable ());
+                       requests = Hashtable.Synchronized (new Hashtable ());
+                       conn = kqueue();
+                       if (conn == -1) {
+                               failed = true;
+                               watcher = null;
+                               return false;
+                       }
+
+                       instance = new KeventWatcher ();
+                       watcher = instance;
+                       return true;
                }
                
                public void StartDispatching (FileSystemWatcher fsw)