network: properly react to being awoken due to a timeout
@@ -485,6 +485,12 @@ static int net_connect_async(int fd,
return -1;
}
+ if (u_conn->net_error == ETIMEDOUT) {
+ flb_debug("[net] TCP connection timed out: %s:%i",
+ u->tcp_host, u->tcp_port);
+ return -1;
+ }
+
/* Check the connection status */
if (mask & MK_EVENT_WRITE) {
error = flb_socket_error(u_conn->fd);
@@ -1313,6 +1319,17 @@ flb_sockfd_t flb_net_tcp_connect(const char *host, unsigned long port,
(char *) host, port, connect_timeout);
}
+ if (u_conn->net_error == ETIMEDOUT) {
+ /* flb_upstream_conn_timeouts called prepare_destroy_conn which
+ * closed the file descriptor and removed it from the event so
+ * we can safely ignore it.
+ */
+
+ fd = -1;
+
+ break;
+ }
+
if (ret == -1) {
address[0] = '\0';
