MCPcopy Create free account
hub / github.com/COVESA/vsomeip / close_socket_unlocked

Method close_socket_unlocked

implementation/endpoints/src/client_endpoint_impl.cpp:666–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664
665template<typename Protocol>
666void client_endpoint_impl<Protocol>::close_socket_unlocked(bool _recreate_socket) {
667
668 if (socket_->is_open()) {
669#if defined(__linux__) || defined(__QNX__)
670 if (!socket_->can_read_fd_flags()) {
671 VSOMEIP_ERROR_P << "Socket/handle closed already, errno " << errno << ", " << get_remote_information() << " endpoint > "
672 << this;
673 }
674#endif
675
676 // NOTE: no `shutdown`, as it will cause a TCP FIN if the underlying protocol is TCP, whereas we want
677 // only TCP RSTs (and therefore configure SO_LINGER accordingly)
678 boost::system::error_code its_error;
679 socket_->close(its_error);
680 if (its_error) {
681 VSOMEIP_WARNING_P << "Socket close error, (" << its_error.value() << "): " << its_error.message()
682 << ", remote: " << get_remote_information() << ", endpoint > " << this << " socket state > "
683 << to_string(state_.load());
684 }
685 } else {
686 VSOMEIP_WARNING_P << "Socket was not open, remote: " << get_remote_information() << ", endpoint > " << this << " socket state > "
687 << to_string(state_.load());
688 }
689
690 state_ = cei_state_e::CLOSED;
691
692 if (_recreate_socket) {
693 recreate_socket();
694 VSOMEIP_WARNING_P << "Socket has been reset, remote: " << get_remote_information() << ", endpoint > " << this << " socket state > "
695 << to_string(state_.load());
696 } else {
697 VSOMEIP_INFO_P << "Not recreating socket, remote: " << get_remote_information() << ", endpoint > " << this << " socket state > "
698 << to_string(state_.load());
699 }
700}
701
702template<typename Protocol>
703bool client_endpoint_impl<Protocol>::get_remote_address(boost::asio::ip::address& _address) const {

Callers 1

restartMethod · 0.80

Calls 6

messageMethod · 0.80
to_stringFunction · 0.70
is_openMethod · 0.45
can_read_fd_flagsMethod · 0.45
closeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected