Commit cf0ae5e6 cf0ae5e630707640609ef90ff1b21ff6077a2fc1 by Christian Gerdes

Added more thread safty to ClearSSLSessions

Now it should be safe to use even if another thread is in the middle of storing a session before we disable it.
1 parent 2276a81d
...@@ -75,7 +75,8 @@ namespace LIL_VSTT_Plugins ...@@ -75,7 +75,8 @@ namespace LIL_VSTT_Plugins
75 System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); 75 System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream));
76 Type t = asm.GetType("System.Net.Security.SslSessionsCache"); 76 Type t = asm.GetType("System.Net.Security.SslSessionsCache");
77 System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); 77 System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
78 f.SetValue(null, new ZeroHashtable()); 78 lock (f.GetValue(null))
79 f.SetValue(null, new ZeroHashtable());
79 } 80 }
80 81
81 void undoIt() 82 void undoIt()
...@@ -83,7 +84,8 @@ namespace LIL_VSTT_Plugins ...@@ -83,7 +84,8 @@ namespace LIL_VSTT_Plugins
83 System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream)); 84 System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(System.Net.Security.SslStream));
84 Type t = asm.GetType("System.Net.Security.SslSessionsCache"); 85 Type t = asm.GetType("System.Net.Security.SslSessionsCache");
85 System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); 86 System.Reflection.FieldInfo f = t.GetField("s_CachedCreds", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
86 f.SetValue(null, new System.Collections.Hashtable(32)); 87 lock (f.GetValue(null))
88 f.SetValue(null, new System.Collections.Hashtable(32));
87 } 89 }
88 } 90 }
89 91
......