Skip to content

Commit fc561cc

Browse files
committed
fix
1 parent ee3fad2 commit fc561cc

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/Channel.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ public extension SSH {
228228
#if DEBUG
229229
print("取消所有定时器和socket源")
230230
#endif
231-
if let socketSource = socketSource {
232-
socketSource.cancel()
233-
self.socketSource = nil
234-
}
231+
socketSource?.cancel()
232+
socketSource = nil
235233
}
236234
}

src/SSH.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ public class SSH {
141141
sockfd = LIBSSH2_INVALID_SOCKET
142142
case .session:
143143
if let rawSession {
144-
job.cancelAllOperations()
145-
cancelKeepalive()
146-
cancelSources()
147144
shutdown(SHUT_RD)
148-
close(.channel)
149-
close(.sftp)
145+
job.cancelAllOperations()
150146
lockRow.lock()
151147
defer {
152148
lockRow.unlock()
153149
}
150+
cancelKeepalive()
151+
cancelSources()
152+
close(.channel)
153+
close(.sftp)
154154
_ = callSSH2 {
155155
libssh2_session_disconnect_ex(rawSession, SSH_DISCONNECT_BY_APPLICATION, "SSH Term: Disconnect", "")
156156
}

src/Session.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,8 @@ public extension SSH {
326326

327327
// 取消心跳包
328328
func cancelKeepalive() {
329-
if let keepAliveSource = keepAliveSource {
330-
keepAliveSource.cancel()
331-
self.keepAliveSource = nil
332-
}
329+
keepAliveSource?.cancel()
330+
keepAliveSource = nil
333331
}
334332

335333
// 发送心跳包以保持连接活跃

src/String+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ extension String {
3232
}
3333

3434
func trim() -> String {
35-
trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
35+
trimmingCharacters(in: .whitespacesAndNewlines)
3636
}
3737
}

0 commit comments

Comments
 (0)