private void RemoveProtocolProvider(string protocol, string nodeid) { // @note this is ugly, locking, but it deals with a race condition on protocol removal lock (mProtocols) { if (mProtocols.TryGetValue(protocol, out Protocol proto)) { if (proto.InternalProviders.TryRemove(nodeid, out Protocol.Provider provider)) { Logger.LogInformation("Protocol provider removed '{0}' from '{1}'", nodeid, protocol); OnProtocolProviderRemove?.Invoke(mSession, proto, provider); if (proto.InternalProviders.Count == 0) { // @note possible race condition here if we don't lock mProtocols on entire add/remove processes if (mProtocols.TryRemove(protocol, out proto)) { Logger.LogInformation("Protocol removed '{0}'", protocol); OnProtocolRemove?.Invoke(mSession, protocol); } } } } } }
private void RemoveProtocolUncertified(string protocol) { if (mProtocolsUncertified.TryRemove(protocol, out bool unused)) { Logger.LogInformation("Protocol removed '{0}'", protocol); OnProtocolRemove?.Invoke(mSession, protocol); } }