Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix route problem when listen on 0.0.0.0 #101

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions python/xoscar/backends/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
ServerClosed,
)
from ..metrics import init_metrics
from ..utils import implements, register_asyncio_task_timeout_detector
from ..utils import implements, is_zero_ip, register_asyncio_task_timeout_detector
from .allocate_strategy import AddressSpecified, allocated_type
from .communication import (
Channel,
Expand Down Expand Up @@ -164,7 +164,10 @@ def __init__(
):
# register local pool for local actor lookup.
# The pool is weakrefed, so we don't need to unregister it.
register_local_pool(external_address, self)
if not is_zero_ip(external_address):
# Only register_local_pool when we listen on non-zero ip (because all-zero ip is wildcard address),
# avoid mistaken with another remote service listen on non-zero ip with the same port.
register_local_pool(external_address, self)
self.process_index = process_index
self.label = label
self.external_address = external_address
Expand Down
4 changes: 4 additions & 0 deletions python/xoscar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,10 @@ def is_v6_zero_ip(ip_port_addr: str) -> bool:
return True


def is_zero_ip(ip_port_addr: str) -> bool:
return is_v4_zero_ip(ip_port_addr) or is_v6_zero_ip(ip_port_addr)


def is_v6_ip(ip_port_addr: str) -> bool:
arr = ip_port_addr.split("://", 1)[-1].split(":")
return len(arr) > 1
Expand Down
Loading