MCPcopy Create free account
hub / github.com/SFML/SFML / disconnect

Method disconnect

src/SFML/Network/Sftp.cpp:654–693  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

652
653////////////////////////////////////////////////////////////
654Sftp::Result Sftp::disconnect(const TimeoutWithPredicate& timeout)
655{
656 // Clear the cached home path
657 m_impl->cachedHomePath.clear();
658
659 // Shut down the SFTP session
660 if (m_impl->sftpSession)
661 {
662 auto* sftpSession = m_impl->sftpSession.release();
663 const auto result = m_impl->waitForOperationComplete([&] { return libssh2_sftp_shutdown(sftpSession); }, timeout);
664
665 if (result == LIBSSH2_ERROR_EAGAIN)
666 return Result(Result::Value::Timeout);
667 }
668
669 // Disconnect the SSH session
670 if (m_impl->ssh2Session)
671 {
672 const auto result = m_impl->waitForOperationComplete(
673 [&]
674 { return libssh2_session_disconnect_ex(m_impl->ssh2Session.get(), SSH_DISCONNECT_BY_APPLICATION, "", ""); },
675 timeout);
676
677 if (result == LIBSSH2_ERROR_EAGAIN)
678 return Result(Result::Value::Timeout);
679
680 // Continue with destroying the SSH session and disconnecting the socket even if an error occurred
681 }
682
683 // Destroy the SSH session
684 m_impl->ssh2Session.reset();
685
686 // Disconnect the TCP connection
687 m_impl->selectorRecv.clear();
688 m_impl->selectorSend.clear();
689 m_impl->selectorEither.clear();
690 m_impl->socket.disconnect();
691
692 return Result(Result::Value::Success);
693}
694
695
696////////////////////////////////////////////////////////////

Callers 1

connectMethod · 0.45

Calls 5

getMethod · 0.80
resetMethod · 0.80
clearMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected