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

Method init

implementation/endpoints/src/local_acceptor_uds_impl.cpp:26–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24local_acceptor_uds_impl::~local_acceptor_uds_impl() = default;
25
26void local_acceptor_uds_impl::init(boost::system::error_code& _ec, std::optional<int> _native_fd) {
27 std::scoped_lock const lock{mtx_};
28 if (_native_fd) {
29 acceptor_->assign(own_endpoint_.protocol(), *_native_fd, _ec);
30 if (_ec) {
31 VSOMEIP_ERROR_P << "Could not assign() acceptor " << own_endpoint_.path() << " , with fd: " << *_native_fd << " due to err "
32 << _ec.message() << ", mem: " << this;
33 return;
34 }
35 } else {
36 acceptor_->open(own_endpoint_.protocol(), _ec);
37 if (_ec) {
38 VSOMEIP_ERROR_P << "Could not open() acceptor " << own_endpoint_.path() << " due to err " << _ec.message() << ", mem: " << this;
39 return;
40 }
41 }
42
43 auto close = [this](char const* _method, boost::system::error_code const& _error_code) {
44 VSOMEIP_ERROR_P << "Error encountered when calling: " << _method << ". Error: " << _error_code.message()
45 << ", for socket: " << own_endpoint_.path() << ", mem: " << this;
46 boost::system::error_code ec;
47 acceptor_->close(ec);
48 if (ec) {
49 VSOMEIP_ERROR_P << "Could not close socket for " << own_endpoint_.path() << ", mem: " << this;
50 }
51 };
52 acceptor_->set_reuse_address(_ec);
53 if (_ec) {
54 close("set_option(reuse_address)", _ec);
55 return;
56 }
57
58 if (!acceptor_->unlink(own_endpoint_.path().c_str())) {
59 VSOMEIP_ERROR_P << "unlink(" << own_endpoint_.path() << ") failed due to errno " << errno << ", mem: " << this;
60 }
61
62 acceptor_->bind(own_endpoint_, _ec);
63 if (_ec) {
64 close("bind", _ec);
65 return;
66 }
67
68 acceptor_->listen(boost::asio::socket_base::max_listen_connections, _ec);
69 if (_ec) {
70 close("listen", _ec);
71 return;
72 }
73
74#ifndef __QNX__
75 if (chmod(own_endpoint_.path().c_str(), configuration_->get_permissions_uds()) == -1) {
76 VSOMEIP_ERROR_P << "chmod: " << strerror(errno) << ", mem: " << this;
77 }
78#endif
79}
80
81void local_acceptor_uds_impl::close(boost::system::error_code& _ec) {
82 std::scoped_lock const lock{mtx_};

Callers

nothing calls this directly

Calls 10

messageMethod · 0.80
get_permissions_udsMethod · 0.80
assignMethod · 0.45
protocolMethod · 0.45
openMethod · 0.45
closeMethod · 0.45
set_reuse_addressMethod · 0.45
unlinkMethod · 0.45
bindMethod · 0.45
listenMethod · 0.45

Tested by

no test coverage detected