WebConnectionGroup.Close() calls WebConnection.Close(), which takes connection lock and then takes the service point lock. Calling WebConnectionGroup.Close() leads to taking the service point lock *before* the connection lock, which leads to a deadlock.
}
public bool CloseConnectionGroup (string connectionGroupName)
{
+ WebConnectionGroup cncGroup = null;
+
lock (this) {
- WebConnectionGroup cncGroup = GetConnectionGroup (connectionGroupName);
+ cncGroup = GetConnectionGroup (connectionGroupName);
if (cncGroup != null) {
- cncGroup.Close ();
RemoveConnectionGroup (cncGroup);
- return true;
}
}
+ // WebConnectionGroup.Close() must *not* be called inside the lock
+ if (cncGroup != null) {
+ cncGroup.Close ();
+ return true;
+ }
+
return false;
}