Skip to content

Commit

Permalink
distributed: bind only to 127.0.0.1 for local-only usage (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlpinDale authored Jan 1, 2025
1 parent 58aff37 commit f81e7d7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions aphrodite/distributed/device_communicators/shm_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def __init__(
# see http://api.zeromq.org/3-3:zmq-setsockopt for more details
self.local_socket.setsockopt(XPUB_VERBOSE, True)
local_subscribe_port = get_open_port()
self.local_socket.bind(f"tcp://*:{local_subscribe_port}")
socket_addr = f"tcp://127.0.0.1:{local_subscribe_port}"
logger.debug(f"Binding to {socket_addr}")
self.local_socket.bind(socket_addr)

self.current_idx = 0

Expand All @@ -210,7 +212,8 @@ def __init__(
self.remote_socket = context.socket(XPUB)
self.remote_socket.setsockopt(XPUB_VERBOSE, True)
remote_subscribe_port = get_open_port()
self.remote_socket.bind(f"tcp://*:{remote_subscribe_port}")
socket_addr = f"tcp://*:{remote_subscribe_port}"
self.remote_socket.bind(socket_addr)

else:
remote_subscribe_port = None
Expand Down Expand Up @@ -254,8 +257,9 @@ def create_from_handle(handle: Handle, rank) -> "MessageQueue":

self.local_socket = context.socket(SUB)
self.local_socket.setsockopt_string(SUBSCRIBE, "")
self.local_socket.connect(
f"tcp://{handle.connect_ip}:{handle.local_subscribe_port}")
socket_addr = f"tcp://127.0.0.1:{handle.local_subscribe_port}"
logger.debug(f"Connecting to {socket_addr}")
self.local_socket.connect(socket_addr)

self.remote_socket = None
else:
Expand All @@ -269,8 +273,9 @@ def create_from_handle(handle: Handle, rank) -> "MessageQueue":

self.remote_socket = context.socket(SUB)
self.remote_socket.setsockopt_string(SUBSCRIBE, "")
self.remote_socket.connect(
f"tcp://{handle.connect_ip}:{handle.remote_subscribe_port}")
socket_addr = f"tcp://{handle.connect_ip}:{handle.remote_subscribe_port}"
logger.debug(f"Connecting to {socket_addr}")
self.remote_socket.connect(socket_addr)

return self

Expand Down

0 comments on commit f81e7d7

Please sign in to comment.