| 109 | } |
| 110 | |
| 111 | void local_server::accept_cbk(boost::system::error_code const& _ec, std::shared_ptr<local_socket> _socket, uint32_t _lc_count) { |
| 112 | if (!_ec) { |
| 113 | std::scoped_lock const lock{mtx_}; |
| 114 | if (_lc_count != lc_count_) { |
| 115 | VSOMEIP_WARNING_P << "Dropping connection from former lifecycle: " << _lc_count << ", current lc: " << lc_count_; |
| 116 | _socket->stop(true); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | boost::asio::ip::tcp::endpoint const peer_endpoint = _socket->peer_endpoint(); |
| 121 | if (std::find(blocked_addresses_.begin(), blocked_addresses_.end(), peer_endpoint.address()) != blocked_addresses_.end()) { |
| 122 | VSOMEIP_WARNING_P << "connection from client @ " << peer_endpoint.address().to_string() << ":" << peer_endpoint.port() |
| 123 | << " rejected, dropping connection, self: " << this; |
| 124 | |
| 125 | _socket->stop(true); |
| 126 | start_unlock(lc_count_); |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | auto connection = std::make_shared<tmp_connection>(std::move(_socket), is_router_, _lc_count, weak_from_this(), configuration_); |
| 131 | connection->async_receive(); |
| 132 | start_unlock(lc_count_); |
| 133 | return; |
| 134 | } |
| 135 | if (_ec != boost::asio::error::operation_aborted) { |
| 136 | if (_ec != boost::asio::error::not_connected) { |
| 137 | VSOMEIP_WARNING_P << "Received error: " << _ec.message() << ", self: " << this; |
| 138 | } else { |
| 139 | VSOMEIP_ERROR_P << "Received error: " << _ec.message() << ", self: " << this; |
| 140 | } |
| 141 | if (_ec == boost::asio::error::bad_descriptor) { |
| 142 | auto log_problem = [mem = this] { |
| 143 | VSOMEIP_FATAL_P << "async_accept: Bad descriptors can not be dealt with. Lingering in a very bad state, self: " << mem; |
| 144 | return true; |
| 145 | }; |
| 146 | log_problem(); |
| 147 | std::scoped_lock const lock{mtx_}; |
| 148 | debounce_ = timer::create(io_, std::chrono::milliseconds(200), log_problem); |
| 149 | debounce_->start(); |
| 150 | return; |
| 151 | } |
| 152 | if (_ec == boost::asio::error::no_descriptors) { |
| 153 | std::scoped_lock const lock{mtx_}; |
| 154 | if (!debounce_) { |
| 155 | debounce_ = timer::create(io_, std::chrono::milliseconds(1000), [weak_self = weak_from_this(), _lc = lc_count_] { |
| 156 | if (auto self = weak_self.lock(); self) { |
| 157 | std::scoped_lock const inner_lock{self->mtx_}; |
| 158 | if (_lc == self->lc_count_) { |
| 159 | VSOMEIP_INFO_P << "Retrying to accept connections, after debounce, self: " << self.get(); |
| 160 | self->start_unlock(_lc); |
| 161 | } else { |
| 162 | VSOMEIP_WARNING_P << "Stopping current retry from the lifecycle: " << _lc << ", current lc: " << self->lc_count_ |
| 163 | << ", self: " << self.get(); |
| 164 | } |
| 165 | } |
| 166 | return false; |
| 167 | }); |
| 168 | } |
no test coverage detected