mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Fix ring
This commit is contained in:
@@ -336,7 +336,7 @@ std::vector<int> accept_connections(
|
||||
for (auto& address : addresses) {
|
||||
detail::TCPSocket socket(RING_TAG);
|
||||
socket.listen(RING_TAG, address);
|
||||
sockets.push_back(socket.accept(RING_TAG));
|
||||
sockets.push_back(socket.accept(RING_TAG).detach());
|
||||
}
|
||||
|
||||
return sockets;
|
||||
@@ -354,21 +354,22 @@ std::vector<int> make_connections(
|
||||
|
||||
for (auto& address : addresses) {
|
||||
sockets.push_back(detail::TCPSocket::connect(
|
||||
RING_TAG,
|
||||
address,
|
||||
CONN_ATTEMPTS,
|
||||
CONN_WAIT,
|
||||
[verbose](int attempt, int wait) {
|
||||
log_info(
|
||||
verbose,
|
||||
"Attempt",
|
||||
attempt,
|
||||
"waiting",
|
||||
wait,
|
||||
"ms (error:",
|
||||
errno,
|
||||
")");
|
||||
}));
|
||||
RING_TAG,
|
||||
address,
|
||||
CONN_ATTEMPTS,
|
||||
CONN_WAIT,
|
||||
[verbose](int attempt, int wait) {
|
||||
log_info(
|
||||
verbose,
|
||||
"Attempt",
|
||||
attempt,
|
||||
"waiting",
|
||||
wait,
|
||||
"ms (error:",
|
||||
errno,
|
||||
")");
|
||||
})
|
||||
.detach());
|
||||
}
|
||||
|
||||
return sockets;
|
||||
|
||||
@@ -80,6 +80,12 @@ TCPSocket::~TCPSocket() {
|
||||
}
|
||||
}
|
||||
|
||||
int TCPSocket::detach() {
|
||||
int s = sock_;
|
||||
sock_ = -1;
|
||||
return s;
|
||||
}
|
||||
|
||||
void TCPSocket::listen(const char* tag, const address_t& addr) {
|
||||
int success;
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ class TCPSocket {
|
||||
void send(const char* tag, const void* data, size_t len);
|
||||
void recv(const char* tag, void* data, size_t len);
|
||||
|
||||
int detach();
|
||||
|
||||
operator int() const {
|
||||
return sock_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user