Skip to content

Commit e257f31

Browse files
committed
add reentrancy check to connect()
If already connecting or reconnecting when connect() is called, throw new connectionAlreadyInProgress error.
1 parent fb50252 commit e257f31

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Sources/SwiftOCA/OCF/Errors.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public enum Ocp1Error: Error, Equatable {
2121
case alreadySubscribedToEvent
2222
case arrayOrDataTooBig
2323
case bonjourRegistrationFailed
24+
case connectionAlreadyInProgress
2425
case connectionTimeout
2526
case duplicateObject(OcaONo)
2627
case endpointAlreadyRegistered

Sources/SwiftOCA/OCP.1/Ocp1Connection+Connect.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ extension Ocp1Connection {
185185
}
186186

187187
public func connect() async throws {
188+
guard !isConnecting else { throw Ocp1Error.connectionAlreadyInProgress }
189+
188190
_updateConnectionState(.connecting)
189191

190192
do {

0 commit comments

Comments
 (0)