@@ -100,37 +100,24 @@ ServerClusterInterface * ServerClusterInterfaceRegistry::Unregister(const Concre
100
100
VerifyOrReturnValue (endpointClusters != nullptr , nullptr );
101
101
VerifyOrReturnValue (endpointClusters->firstCluster != nullptr , nullptr );
102
102
103
- if (endpointClusters->firstCluster ->GetClusterId () == path.mClusterId )
104
- {
105
- ServerClusterInterface * previous = endpointClusters->firstCluster ;
106
- endpointClusters->firstCluster = endpointClusters->firstCluster ->GetNextListItem ();
107
-
108
- if (endpointClusters->firstCluster == nullptr )
109
- {
110
- // Free up the endpoint as it has nothing on it.
111
- UnregisterAllFromEndpoint (endpointClusters->endpointId );
112
- }
113
-
114
- if (mCachedInterface == previous)
115
- {
116
- mCachedClusterEndpointId = kInvalidEndpointId ;
117
- mCachedInterface = nullptr ;
118
- }
119
- previous->SetNotInList ();
120
-
121
- return previous;
122
- }
123
-
124
- // not found, go through the underlying list and remove any found element
125
- ServerClusterInterface * prev = endpointClusters->firstCluster ;
126
- ServerClusterInterface * current = endpointClusters->firstCluster ->GetNextListItem ();
103
+ ServerClusterInterface * prev = nullptr ;
104
+ ServerClusterInterface * current = endpointClusters->firstCluster ;
127
105
128
106
while (current != nullptr )
129
107
{
130
108
if (current->GetClusterId () == path.mClusterId )
131
109
{
132
110
// takes the item out of the current list and return it.
133
- prev->SetNextListItem (current->GetNextListItem ());
111
+ ServerClusterInterface * next = current->GetNextListItem ();
112
+
113
+ if (prev == nullptr )
114
+ {
115
+ endpointClusters->firstCluster = next;
116
+ }
117
+ else
118
+ {
119
+ prev->SetNextListItem (next);
120
+ }
134
121
135
122
if (mCachedInterface == current)
136
123
{
0 commit comments