Commit 0c3af626 authored by octal's avatar octal

Client: failing to connect will now be detected

parent 76db321d
...@@ -165,20 +165,22 @@ Transport::onReady(const Io::FdSet& fds) { ...@@ -165,20 +165,22 @@ Transport::onReady(const Io::FdSet& fds) {
} }
} }
} }
else if (entry.isWritable()) { else {
auto tag = entry.getTag(); auto tag = entry.getTag();
auto fd = tag.value(); auto fd = tag.value();
auto connIt = connections.find(fd); auto connIt = connections.find(fd);
if (connIt != std::end(connections)) { if (connIt != std::end(connections)) {
auto& conn = connIt->second; auto& conn = connIt->second;
conn.resolve(); if (entry.isHangup())
// We are connected, we can start reading data now conn.reject(Error::system("Could not connect"));
io()->modifyFd(conn.connection->fd, NotifyOn::Read); else {
continue; conn.resolve();
// We are connected, we can start reading data now
io()->modifyFd(conn.connection->fd, NotifyOn::Read);
}
} else {
throw std::runtime_error("Unknown fd");
} }
throw std::runtime_error("Unknown fd");
} }
} }
} }
...@@ -292,7 +294,7 @@ Transport::handleConnectionQueue() { ...@@ -292,7 +294,7 @@ Transport::handleConnectionQueue() {
int res = ::connect(conn->fd, data.addr, data.addr_len); int res = ::connect(conn->fd, data.addr, data.addr_len);
if (res == -1) { if (res == -1) {
if (errno == EINPROGRESS) { if (errno == EINPROGRESS) {
io()->registerFdOneShot(conn->fd, NotifyOn::Write); io()->registerFdOneShot(conn->fd, NotifyOn::Write | NotifyOn::Hangup | NotifyOn::Shutdown);
} }
else { else {
data.reject(Error::system("Failed to connect")); data.reject(Error::system("Failed to connect"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment