Bind the MessageQueue remote socket atomically (#42695)
Co-authored-by: merrymercy <merrymercy@users.noreply.github.com> Co-authored-by: charlotte12l <charlotte12l@users.noreply.github.com>
This commit is contained in:
co-authored by
merrymercy
charlotte12l
parent
44a2558d40
commit
6b737fd4c6
@@ -239,9 +239,12 @@ class MessageQueue:
|
||||
na = NetworkAddress(connect_ip, remote_subscribe_port)
|
||||
if na.is_ipv6:
|
||||
self.remote_socket.setsockopt(IPV6, 1)
|
||||
address = na.to_tcp()
|
||||
logger.debug(f"class MessageQueue: Binding remote socket to {address=}")
|
||||
self.remote_socket.bind(address)
|
||||
# get_open_port() only probes; bind atomically in a window from that port.
|
||||
remote_subscribe_port = self.remote_socket.bind_to_random_port(
|
||||
na.to_tcp().rsplit(":", 1)[0], # address without the port
|
||||
min_port=remote_subscribe_port,
|
||||
max_port=remote_subscribe_port + 32,
|
||||
)
|
||||
|
||||
else:
|
||||
remote_subscribe_port = None
|
||||
|
||||
Reference in New Issue
Block a user