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) {
|
for (auto& address : addresses) {
|
||||||
detail::TCPSocket socket(RING_TAG);
|
detail::TCPSocket socket(RING_TAG);
|
||||||
socket.listen(RING_TAG, address);
|
socket.listen(RING_TAG, address);
|
||||||
sockets.push_back(socket.accept(RING_TAG));
|
sockets.push_back(socket.accept(RING_TAG).detach());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sockets;
|
return sockets;
|
||||||
@@ -354,21 +354,22 @@ std::vector<int> make_connections(
|
|||||||
|
|
||||||
for (auto& address : addresses) {
|
for (auto& address : addresses) {
|
||||||
sockets.push_back(detail::TCPSocket::connect(
|
sockets.push_back(detail::TCPSocket::connect(
|
||||||
RING_TAG,
|
RING_TAG,
|
||||||
address,
|
address,
|
||||||
CONN_ATTEMPTS,
|
CONN_ATTEMPTS,
|
||||||
CONN_WAIT,
|
CONN_WAIT,
|
||||||
[verbose](int attempt, int wait) {
|
[verbose](int attempt, int wait) {
|
||||||
log_info(
|
log_info(
|
||||||
verbose,
|
verbose,
|
||||||
"Attempt",
|
"Attempt",
|
||||||
attempt,
|
attempt,
|
||||||
"waiting",
|
"waiting",
|
||||||
wait,
|
wait,
|
||||||
"ms (error:",
|
"ms (error:",
|
||||||
errno,
|
errno,
|
||||||
")");
|
")");
|
||||||
}));
|
})
|
||||||
|
.detach());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sockets;
|
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) {
|
void TCPSocket::listen(const char* tag, const address_t& addr) {
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class TCPSocket {
|
|||||||
void send(const char* tag, const void* data, size_t len);
|
void send(const char* tag, const void* data, size_t len);
|
||||||
void recv(const char* tag, void* data, size_t len);
|
void recv(const char* tag, void* data, size_t len);
|
||||||
|
|
||||||
|
int detach();
|
||||||
|
|
||||||
operator int() const {
|
operator int() const {
|
||||||
return sock_;
|
return sock_;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user