Skip to content

Commit a0c0b80

Browse files
committed
Merge branch 'release/0.22.3/master'
2 parents f72d529 + c267289 commit a0c0b80

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## Changes in 0.22.3 (2022-02-24)
2+
3+
🐛 Bugfixes
4+
5+
- Thread Safety: Replace all objc_sync_enter/exit methods with recursive locks. ([#5675](https://github.com/vector-im/element-ios/issues/5675))
6+
7+
18
## Changes in 0.22.2 (2022-02-22)
29

310
🙌 Improvements

MatrixSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "MatrixSDK"
4-
s.version = "0.22.2"
4+
s.version = "0.22.3"
55
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"
66

77
s.description = <<-DESC

MatrixSDK/Data/EventTimeline/Thread/MXThreadEventTimeline.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class MXThreadEventTimeline: NSObject, MXEventTimeline {
5555

5656
/// The current pending request
5757
private var currentHttpOperation: MXHTTPOperation?
58+
private let lockListeners = NSRecursiveLock()
5859

5960
private lazy var threadEventFilter: MXRoomEventFilter = {
6061
let filter = MXRoomEventFilter()
@@ -439,9 +440,9 @@ public class MXThreadEventTimeline: NSObject, MXEventTimeline {
439440

440441
/// Thread safe access to listeners array
441442
private func synchronizeListeners(_ block: () -> Void) {
442-
objc_sync_enter(listeners)
443+
lockListeners.lock()
444+
defer { lockListeners.unlock() }
443445
block()
444-
objc_sync_exit(listeners)
445446
}
446447

447448
private func fixRoomId(inEvents events: [MXEvent]) {

MatrixSDK/MatrixSDKVersion.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
NSString *const MatrixSDKVersion = @"0.22.2";
19+
NSString *const MatrixSDKVersion = @"0.22.3";

MatrixSDK/Threads/MXThreadingService.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class MXThreadingService: NSObject {
4646

4747
private weak var session: MXSession?
4848

49+
private let lockThreads = NSRecursiveLock()
4950
private var threads: [String: MXThread] = [:]
5051
private let multicastDelegate: MXMulticastDelegate<MXThreadingServiceDelegate> = MXMulticastDelegate()
5152

@@ -110,10 +111,9 @@ public class MXThreadingService: NSObject {
110111
/// - Parameter identifier: identifier of a thread
111112
/// - Returns: thread instance if found, nil otherwise
112113
public func thread(withId identifier: String) -> MXThread? {
113-
objc_sync_enter(threads)
114-
let result = threads[identifier]
115-
objc_sync_exit(threads)
116-
return result
114+
lockThreads.lock()
115+
defer { lockThreads.unlock() }
116+
return threads[identifier]
117117
}
118118

119119
public func createTempThread(withId identifier: String, roomId: String) -> MXThread {
@@ -308,9 +308,9 @@ public class MXThreadingService: NSObject {
308308
}
309309

310310
private func saveThread(_ thread: MXThread) {
311-
objc_sync_enter(threads)
311+
lockThreads.lock()
312+
defer { lockThreads.unlock() }
312313
threads[thread.id] = thread
313-
objc_sync_exit(threads)
314314
}
315315

316316
// MARK: - Delegate

MatrixSDK/Utils/MXMulticastDelegate.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class MXMulticastDelegate <T: AnyObject> {
2222
/// Weakly referenced delegates
2323
private let delegates: NSHashTable<T> = NSHashTable.weakObjects()
2424
private let dispatchQueue: DispatchQueue
25+
private let lockDelegates = NSRecursiveLock()
2526

2627
/// Initializer
2728
/// - Parameter dispatchQueue: Queue to invoke delegate methods
@@ -70,9 +71,9 @@ public class MXMulticastDelegate <T: AnyObject> {
7071

7172
/// Thread safe access to delegates array
7273
private func synchronizeDelegates(_ block: () -> Void) {
73-
objc_sync_enter(delegates)
74+
lockDelegates.lock()
75+
defer { lockDelegates.unlock() }
7476
block()
75-
objc_sync_exit(delegates)
7677
}
7778

7879
deinit {

0 commit comments

Comments
 (0)