| 99 | } |
| 100 | |
| 101 | void socket_manager::remove(fd_t fd) { |
| 102 | auto const lock = std::scoped_lock(mtx_); |
| 103 | fd_to_handle_.erase(fd); |
| 104 | |
| 105 | for (auto it = multicast_to_fds_.begin(); it != multicast_to_fds_.end();) { |
| 106 | auto& [address, fds] = *it; |
| 107 | if (auto it_fds = fds.find(fd); it_fds != fds.end()) { |
| 108 | fds.erase(it_fds); |
| 109 | if (fds.empty()) { |
| 110 | it = multicast_to_fds_.erase(it); |
| 111 | continue; |
| 112 | } |
| 113 | } |
| 114 | ++it; |
| 115 | } |
| 116 | |
| 117 | for (auto it_apps = binded_multicast_endpoints_.begin(); it_apps != binded_multicast_endpoints_.end();) { |
| 118 | for (auto it_endpoints = it_apps->second.begin(); it_endpoints != it_apps->second.end();) { |
| 119 | if (it_endpoints->second == fd) { |
| 120 | it_endpoints = it_apps->second.erase(it_endpoints); |
| 121 | continue; |
| 122 | } |
| 123 | ++it_endpoints; |
| 124 | } |
| 125 | if (it_apps->second.size() == 0) { |
| 126 | it_apps = binded_multicast_endpoints_.erase(it_apps); |
| 127 | continue; |
| 128 | } |
| 129 | ++it_apps; |
| 130 | } |
| 131 | |
| 132 | auto it_udp = std::find_if(endpoint_udp_to_fd_.begin(), endpoint_udp_to_fd_.end(), [fd](const auto& _fd) { return _fd.second == fd; }); |
| 133 | if (it_udp != endpoint_udp_to_fd_.end()) { |
| 134 | endpoint_udp_to_fd_.erase(it_udp); |
| 135 | } |
| 136 | |
| 137 | auto it_tcp = std::find_if(endpoint_tcp_to_fd_.begin(), endpoint_tcp_to_fd_.end(), [fd](const auto& _fd) { return _fd.second == fd; }); |
| 138 | if (it_tcp != endpoint_tcp_to_fd_.end()) { |
| 139 | endpoint_tcp_to_fd_.erase(it_tcp); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | void socket_manager::add_acceptor(std::weak_ptr<fake_tcp_acceptor_handle> _state, boost::asio::io_context* _io, socket_type _type) { |
| 144 | if (auto const state = _state.lock(); state) { |
no test coverage detected