Skip to content

Commit 008695c

Browse files
committed
close channel
Calling close on channels when closing connection
1 parent 03eade6 commit 008695c

File tree

7 files changed

+132
-15
lines changed

7 files changed

+132
-15
lines changed

MemoryTestTests/MemoryTestTests.swift

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
1+
// This source code is dual-licensed under the Mozilla Public License ("MPL"),
2+
// version 2.0 and the Apache License ("ASL"), version 2.0.
13
//
2-
// MemoryTestTests.swift
3-
// MemoryTestTests
4+
// The ASL v2.0:
45
//
5-
// Created by Barry Duggan on 01/04/2022.
6-
// Copyright © 2022 VMware. All rights reserved.
6+
// ---------------------------------------------------------------------------
7+
// Copyright 2017-2022 VMware, Inc. or its affiliates.
78
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// https://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
// ---------------------------------------------------------------------------
21+
//
22+
// The MPL v2.0:
23+
//
24+
// ---------------------------------------------------------------------------
25+
// This Source Code Form is subject to the terms of the Mozilla Public
26+
// License, v. 2.0. If a copy of the MPL was not distributed with this
27+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
28+
//
29+
// Copyright (c) 2007-2022 VMware, Inc. or its affiliates. All rights reserved.
30+
//
31+
// Alternatively, the contents of this file may be used under the terms
32+
// of the Apache Standard license (the "ASL License"), in which case the
33+
// provisions of the ASL License are applicable instead of those
34+
// above. If you wish to allow use of your version of this file only
35+
// under the terms of the ASL License and not to allow others to use
36+
// your version of this file under the MPL, indicate your decision by
37+
// deleting the provisions above and replace them with the notice and
38+
// other provisions required by the ASL License. If you do not delete
39+
// the provisions above, a recipient may use your version of this file
40+
// under either the MPL or the ASL License.
41+
// ---------------------------------------------------------------------------
842

943
import XCTest
1044
@testable import MemoryTest

MemoryTestUITests/MemoryTestUITests.swift

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
1+
// This source code is dual-licensed under the Mozilla Public License ("MPL"),
2+
// version 2.0 and the Apache License ("ASL"), version 2.0.
13
//
2-
// MemoryTestUITests.swift
3-
// MemoryTestUITests
4+
// The ASL v2.0:
45
//
5-
// Created by Barry Duggan on 01/04/2022.
6-
// Copyright © 2022 VMware. All rights reserved.
6+
// ---------------------------------------------------------------------------
7+
// Copyright 2017-2022 VMware, Inc. or its affiliates.
78
//
8-
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// https://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
// ---------------------------------------------------------------------------
21+
//
22+
// The MPL v2.0:
23+
//
24+
// ---------------------------------------------------------------------------
25+
// This Source Code Form is subject to the terms of the Mozilla Public
26+
// License, v. 2.0. If a copy of the MPL was not distributed with this
27+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
28+
//
29+
// Copyright (c) 2007-2022 VMware, Inc. or its affiliates. All rights reserved.
30+
//
31+
// Alternatively, the contents of this file may be used under the terms
32+
// of the Apache Standard license (the "ASL License"), in which case the
33+
// provisions of the ASL License are applicable instead of those
34+
// above. If you wish to allow use of your version of this file only
35+
// under the terms of the ASL License and not to allow others to use
36+
// your version of this file under the MPL, indicate your decision by
37+
// deleting the provisions above and replace them with the notice and
38+
// other provisions required by the ASL License. If you do not delete
39+
// the provisions above, a recipient may use your version of this file
40+
// under either the MPL or the ASL License.
41+
// ---------------------------------------------------------------------------
942
import XCTest
1043

1144
class MemoryTestUITests: XCTestCase {

MemoryTestUITests/MemoryTestUITestsLaunchTests.swift

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
1+
// This source code is dual-licensed under the Mozilla Public License ("MPL"),
2+
// version 2.0 and the Apache License ("ASL"), version 2.0.
13
//
2-
// MemoryTestUITestsLaunchTests.swift
3-
// MemoryTestUITests
4+
// The ASL v2.0:
45
//
5-
// Created by Barry Duggan on 01/04/2022.
6-
// Copyright © 2022 VMware. All rights reserved.
6+
// ---------------------------------------------------------------------------
7+
// Copyright 2017-2022 VMware, Inc. or its affiliates.
78
//
8-
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// https://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
// ---------------------------------------------------------------------------
21+
//
22+
// The MPL v2.0:
23+
//
24+
// ---------------------------------------------------------------------------
25+
// This Source Code Form is subject to the terms of the Mozilla Public
26+
// License, v. 2.0. If a copy of the MPL was not distributed with this
27+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
28+
//
29+
// Copyright (c) 2007-2022 VMware, Inc. or its affiliates. All rights reserved.
30+
//
31+
// Alternatively, the contents of this file may be used under the terms
32+
// of the Apache Standard license (the "ASL License"), in which case the
33+
// provisions of the ASL License are applicable instead of those
34+
// above. If you wish to allow use of your version of this file only
35+
// under the terms of the ASL License and not to allow others to use
36+
// your version of this file under the MPL, indicate your decision by
37+
// deleting the provisions above and replace them with the notice and
38+
// other provisions required by the ASL License. If you do not delete
39+
// the provisions above, a recipient may use your version of this file
40+
// under either the MPL or the ASL License.
41+
// ---------------------------------------------------------------------------
942
import XCTest
1043

1144
class MemoryTestUITestsLaunchTests: XCTestCase {

RMQClient/RMQChannelAllocator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@
4949
- (id<RMQChannel>)allocate;
5050
- (void)releaseChannelNumber:(NSNumber *)channelNumber;
5151
- (NSArray<id<RMQChannel>> *)allocatedUserChannels;
52+
- (void)cleanupOnClose;
53+
5254
@end

RMQClient/RMQConnection.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ - (NSArray *)closeOperationsWithoutBlock {
710710
[self.transport close];
711711
},
712712
^{
713+
[self.channelAllocator cleanupOnClose];
713714
self.channelAllocator = nil;
714715
},
715716
^{
@@ -730,6 +731,7 @@ - (NSArray *)closeOperations {
730731
[self.transport close];
731732
},
732733
^{
734+
[self.channelAllocator cleanupOnClose];
733735
self.channelAllocator = nil;
734736
},
735737
^{

RMQClient/RMQMultipleChannelAllocator.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ - (instancetype)init {
8282
[self doesNotRecognizeSelector:_cmd];
8383
return nil;
8484
}
85-
85+
- (void)cleanupOnClose {
86+
for (id key in self.channels) {
87+
[[self.channels objectForKey:key] close];
88+
}
89+
[self.channels removeAllObjects];
90+
91+
}
8692
- (id<RMQChannel>)allocate {
8793
id<RMQChannel> ch;
8894
@synchronized(self) {

RMQClientTests/ChannelSpyAllocator.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
// ---------------------------------------------------------------------------
4242

4343
@objc class ChannelSpyAllocator: NSObject, RMQChannelAllocator {
44+
4445
var id = 0
4546
var channels: [ChannelSpy] = []
4647
var sender: RMQSender!
@@ -51,6 +52,12 @@
5152
channels.append(ch)
5253
return ch
5354
}
55+
func cleanupOnClose() {
56+
for channel in channels {
57+
channel.close()
58+
}
59+
channels.removeAll()
60+
}
5461

5562
func releaseChannelNumber(_ channelNumber: NSNumber!) {
5663
channels = channels.filter { ch -> Bool in

0 commit comments

Comments
 (0)