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

Method accept_cbk

implementation/endpoints/src/local_server.cpp:111–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void 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 }

Callers 1

start_unlockMethod · 0.95

Calls 11

start_unlockMethod · 0.95
beginMethod · 0.80
endMethod · 0.80
messageMethod · 0.80
lockMethod · 0.80
stopMethod · 0.45
peer_endpointMethod · 0.45
to_stringMethod · 0.45
async_receiveMethod · 0.45
startMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected