Skip to content

Commit

Permalink
Early simple return of connectivity check. Set connection to null on …
Browse files Browse the repository at this point in the history
…disconnect.
  • Loading branch information
frankdejonge committed Mar 16, 2024
1 parent 438824a commit 53ddb77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/PhpseclibV3/SftpConnectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function disconnect(): void
{
if ($this->connection) {
$this->connection->disconnect();
$this->connection = null;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/PhpseclibV3/SimpleConnectivityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class SimpleConnectivityChecker implements ConnectivityChecker
{
public function isConnected(SFTP $connection): bool
{
if ( ! $connection->isConnected()) {
return false;
}

try {
return $connection->ping();
} catch (Throwable) {
Expand Down

0 comments on commit 53ddb77

Please sign in to comment.