Skip to content

Commit d88d1b9

Browse files
committed
Unlock mutex before potentially slow IPv6 address resolution
1 parent 5aa18f7 commit d88d1b9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/inlet_connection.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,23 @@ tcp::endpoint inlet_connection::get_tcp_endpoint() {
130130
shared_lock_t lock(host_info_mut_);
131131
if (tcp_protocol_ == tcp::v4())
132132
return tcp::endpoint(ip::make_address(host_info_.v4address()), host_info_.v4data_port());
133-
else
134-
return tcp::endpoint(resolve_v6_addr(host_info_.v6address()), host_info_.v6data_port());
133+
134+
std::string addr = host_info_.v6address();
135+
uint16_t port = host_info_.v6data_port();
136+
lock.unlock();
137+
return tcp::endpoint(resolve_v6_addr(addr), port);
135138
}
136139

137140
udp::endpoint inlet_connection::get_udp_endpoint() {
138141
shared_lock_t lock(host_info_mut_);
139142

140143
if (udp_protocol_ == udp::v4())
141144
return udp::endpoint(ip::make_address(host_info_.v4address()), host_info_.v4service_port());
142-
else
143-
return udp::endpoint(resolve_v6_addr(host_info_.v6address()), host_info_.v6service_port());
145+
146+
std::string addr = host_info_.v6address();
147+
uint16_t port = host_info_.v6service_port();
148+
lock.unlock();
149+
return udp::endpoint(resolve_v6_addr(addr), port);
144150
}
145151

146152
std::string inlet_connection::current_uid() {

0 commit comments

Comments
 (0)