public virtual void Unregister(UnregisterInfo unregisterInfo) { if (unregisterInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterinfo", System.ServiceModel.SR.GetString("PeerNullRegistrationInfo")); } this.ThrowIfClosed("Unregister"); if ((!unregisterInfo.HasBody() || string.IsNullOrEmpty(unregisterInfo.MeshId)) || (unregisterInfo.RegistrationId == Guid.Empty)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterInfo", System.ServiceModel.SR.GetString("PeerInvalidMessageBody", new object[] { unregisterInfo })); } RegistrationEntry entry = null; MeshEntry meshEntry = this.GetMeshEntry(unregisterInfo.MeshId, false); LiteLock liteLock = null; try { LiteLock.Acquire(out liteLock, meshEntry.Gate, true); if (!meshEntry.EntryTable.TryGetValue(unregisterInfo.RegistrationId, out entry)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterInfo", System.ServiceModel.SR.GetString("PeerInvalidMessageBody", new object[] { unregisterInfo })); } meshEntry.EntryTable.Remove(unregisterInfo.RegistrationId); meshEntry.EntryList.Remove(entry); meshEntry.Service2EntryTable.Remove(entry.Address.ServicePath); entry.State = RegistrationState.Deleted; } finally { LiteLock.Release(liteLock); } }
public virtual void Unregister(UnregisterInfo unregisterInfo) { if (unregisterInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterinfo", SR.GetString(SR.PeerNullRegistrationInfo)); } ThrowIfClosed("Unregister"); if (!unregisterInfo.HasBody() || String.IsNullOrEmpty(unregisterInfo.MeshId) || unregisterInfo.RegistrationId == Guid.Empty) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterInfo", SR.GetString(SR.PeerInvalidMessageBody, unregisterInfo)); } RegistrationEntry registration = null; MeshEntry meshEntry = GetMeshEntry(unregisterInfo.MeshId, false); //there could be a ---- that two different threads could be working on the same entry //we wont optimize for that case. LiteLock ll = null; try { LiteLock.Acquire(out ll, meshEntry.Gate, true); if (!meshEntry.EntryTable.TryGetValue(unregisterInfo.RegistrationId, out registration)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterInfo", SR.GetString(SR.PeerInvalidMessageBody, unregisterInfo)); } meshEntry.EntryTable.Remove(unregisterInfo.RegistrationId); meshEntry.EntryList.Remove(registration); meshEntry.Service2EntryTable.Remove(registration.Address.ServicePath); registration.State = RegistrationState.Deleted; } finally { LiteLock.Release(ll); } }
public virtual void Unregister(UnregisterInfo unregisterInfo) { if (unregisterInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterinfo", SR.GetString(SR.PeerNullRegistrationInfo)); } ThrowIfClosed("Unregister"); if (!unregisterInfo.HasBody() || String.IsNullOrEmpty(unregisterInfo.MeshId) || unregisterInfo.RegistrationId == Guid.Empty) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterInfo", SR.GetString(SR.PeerInvalidMessageBody, unregisterInfo)); } RegistrationEntry registration = null; MeshEntry meshEntry = GetMeshEntry(unregisterInfo.MeshId, false); //there could be a ---- that two different threads could be working on the same entry //we wont optimize for that case. LiteLock ll = null; try { LiteLock.Acquire(out ll, meshEntry.Gate, true); if (!meshEntry.EntryTable.TryGetValue(unregisterInfo.RegistrationId, out registration)) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("unregisterInfo", SR.GetString(SR.PeerInvalidMessageBody, unregisterInfo)); meshEntry.EntryTable.Remove(unregisterInfo.RegistrationId); meshEntry.EntryList.Remove(registration); meshEntry.Service2EntryTable.Remove(registration.Address.ServicePath); registration.State = RegistrationState.Deleted; } finally { LiteLock.Release(ll); } }