Skip to content

Commit 60e8f3c

Browse files
authored
Fix the issue with recursive locking when disposing of a SubscriptionSet (#219)
1 parent 1c6a045 commit 60e8f3c

File tree

6 files changed

+41
-13
lines changed

6 files changed

+41
-13
lines changed

.pubnub.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
---
22
name: swift
33
scm: github.com/pubnub/swift
4-
version: "9.3.0"
4+
version: "9.3.1"
55
schema: 1
66
changelog:
7+
- date: 2025-07-31
8+
version: 9.3.1
9+
changes:
10+
- type: bug
11+
text: "Fix the issue with recursive locking introduced in 9.3.0 when disposing a SubscriptionSet."
712
- date: 2025-07-29
813
version: 9.3.0
914
changes:
@@ -708,7 +713,7 @@ sdks:
708713
- distribution-type: source
709714
distribution-repository: GitHub release
710715
package-name: PubNub
711-
location: https://github.com/pubnub/swift/archive/refs/tags/9.3.0.zip
716+
location: https://github.com/pubnub/swift/archive/refs/tags/9.3.1.zip
712717
supported-platforms:
713718
supported-operating-systems:
714719
macOS:

PubNub.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,7 +4031,7 @@
40314031
"@loader_path/Frameworks",
40324032
);
40334033
MACOSX_DEPLOYMENT_TARGET = 10.15;
4034-
MARKETING_VERSION = 9.3.0;
4034+
MARKETING_VERSION = 9.3.1;
40354035
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
40364036
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
40374037
MTL_FAST_MATH = YES;
@@ -4082,7 +4082,7 @@
40824082
"@loader_path/Frameworks",
40834083
);
40844084
MACOSX_DEPLOYMENT_TARGET = 10.15;
4085-
MARKETING_VERSION = 9.3.0;
4085+
MARKETING_VERSION = 9.3.1;
40864086
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
40874087
MTL_ENABLE_DEBUG_INFO = NO;
40884088
MTL_FAST_MATH = YES;
@@ -4190,7 +4190,7 @@
41904190
"@loader_path/Frameworks",
41914191
);
41924192
MACOSX_DEPLOYMENT_TARGET = 10.15;
4193-
MARKETING_VERSION = 9.3.0;
4193+
MARKETING_VERSION = 9.3.1;
41944194
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
41954195
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
41964196
MTL_FAST_MATH = YES;
@@ -4243,7 +4243,7 @@
42434243
"@loader_path/Frameworks",
42444244
);
42454245
MACOSX_DEPLOYMENT_TARGET = 10.15;
4246-
MARKETING_VERSION = 9.3.0;
4246+
MARKETING_VERSION = 9.3.1;
42474247
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
42484248
MTL_ENABLE_DEBUG_INFO = NO;
42494249
MTL_FAST_MATH = YES;
@@ -4364,7 +4364,7 @@
43644364
"@loader_path/Frameworks",
43654365
);
43664366
MACOSX_DEPLOYMENT_TARGET = 10.15;
4367-
MARKETING_VERSION = 9.3.0;
4367+
MARKETING_VERSION = 9.3.1;
43684368
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
43694369
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
43704370
MTL_FAST_MATH = YES;
@@ -4416,7 +4416,7 @@
44164416
"@loader_path/Frameworks",
44174417
);
44184418
MACOSX_DEPLOYMENT_TARGET = 10.15;
4419-
MARKETING_VERSION = 9.3.0;
4419+
MARKETING_VERSION = 9.3.1;
44204420
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
44214421
MTL_ENABLE_DEBUG_INFO = NO;
44224422
MTL_FAST_MATH = YES;
@@ -4896,7 +4896,7 @@
48964896
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
48974897
);
48984898
MACOSX_DEPLOYMENT_TARGET = 10.15;
4899-
MARKETING_VERSION = 9.3.0;
4899+
MARKETING_VERSION = 9.3.1;
49004900
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14";
49014901
OTHER_CFLAGS = "$(inherited)";
49024902
OTHER_LDFLAGS = "$(inherited)";
@@ -4939,7 +4939,7 @@
49394939
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
49404940
);
49414941
MACOSX_DEPLOYMENT_TARGET = 10.15;
4942-
MARKETING_VERSION = 9.3.0;
4942+
MARKETING_VERSION = 9.3.1;
49434943
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14";
49444944
OTHER_CFLAGS = "$(inherited)";
49454945
OTHER_LDFLAGS = "$(inherited)";

PubNubSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'PubNubSwift'
3-
s.version = '9.3.0'
3+
s.version = '9.3.1'
44
s.homepage = 'https://github.com/pubnub/swift'
55
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
66
s.authors = { 'PubNub, Inc.' => '[email protected]' }

Sources/PubNub/Events/New/SubscriptionSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public final class SubscriptionSet: EventListenerInterface, SubscriptionDisposab
142142
/// Once disposed, the subscription interface cannot be restarted.
143143
public func dispose() {
144144
clearCallbacks()
145-
currentSubscriptions.lockedRead { $0.forEach { $0.dispose() } }
145+
currentSubscriptions.lockedRead { $0 }.forEach { $0.dispose() }
146146
removeAllListeners()
147147
isDisposedContainer.lockedWrite { $0 = true }
148148
}

Sources/PubNub/Helpers/Constants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public enum Constant {
5757

5858
static let pubnubSwiftSDKName: String = "PubNubSwift"
5959

60-
static let pubnubSwiftSDKVersion: String = "9.3.0"
60+
static let pubnubSwiftSDKVersion: String = "9.3.1"
6161

6262
static let appBundleId: String = {
6363
if let info = Bundle.main.infoDictionary,

Tests/PubNubTests/Integration/SubscriptionIntegrationTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,29 @@ class SubscriptionIntegrationTests: XCTestCase {
463463
// Ensuring backward compatibility and that the presence channel is unsubscribed along with the main channel
464464
XCTAssertEqual(pubnub.subscribedChannels.sorted(by: <), ["B", "B-pnpres"])
465465
}
466+
467+
func testSubscriptionSetDispose() {
468+
let expectation = expectation(description: "Test")
469+
let pubnub = PubNub(configuration: .init(from: testsBundle))
470+
let channel = pubnub.channel("test-channel")
471+
let channel2 = pubnub.channel("test-channel2")
472+
let subscriptionSet = pubnub.subscription(entities: [channel, channel2])
473+
474+
subscriptionSet.subscribe()
475+
476+
pubnub.onConnectionStateChange = { [unowned subscriptionSet] newStatus in
477+
switch newStatus {
478+
case .connected:
479+
subscriptionSet.dispose()
480+
XCTAssertTrue(subscriptionSet.isDisposed)
481+
expectation.fulfill()
482+
default:
483+
break
484+
}
485+
}
486+
487+
wait(for: [expectation], timeout: 3)
488+
}
466489
}
467490

468491
private extension SubscriptionIntegrationTests {

0 commit comments

Comments
 (0)