Skip to content
Open
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
21 changes: 16 additions & 5 deletions shard_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,27 @@ int shard_connection::connect(struct connect_info* addr) {
// call connect
m_connection_state = conn_in_progress;

if (bufferevent_socket_connect(m_bev,
m_unix_sockaddr ? (struct sockaddr *) m_unix_sockaddr : addr->ci_addr,
m_unix_sockaddr ? sizeof(struct sockaddr_un) : addr->ci_addrlen) == -1) {
while (true) {
if (bufferevent_socket_connect(m_bev,
m_unix_sockaddr ? (struct sockaddr *) m_unix_sockaddr : addr->ci_addr,
m_unix_sockaddr ? sizeof(struct sockaddr_un) : addr->ci_addrlen) == 0) {
return 0;
}

if (errno == EINPROGRESS) {
return 0;
}

if (errno == EAGAIN || errno == EWOULDBLOCK) {
// resource temporarily unavailable; try again
continue;
}

disconnect();

benchmark_error_log("connect failed, error = %s\n", strerror(errno));
return -1;
}

return 0;
}

void shard_connection::disconnect() {
Expand Down