Skip to content

Commit 234c402

Browse files
committed
io: on network connect exceptions, invalidate fd
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent cbd89b7 commit 234c402

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/flb_io.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,9 @@ int flb_io_net_connect(struct flb_connection *connection,
110110
int async = FLB_FALSE;
111111
flb_sockfd_t fd = -1;
112112
int flags = flb_connection_get_flags(connection);
113-
// struct flb_upstream *u = u_conn->u;
114113

115114
if (connection->fd > 0) {
116115
flb_socket_close(connection->fd);
117-
118116
connection->fd = -1;
119117
connection->event.fd = -1;
120118
}
@@ -146,9 +144,10 @@ int flb_io_net_connect(struct flb_connection *connection,
146144
connection->upstream->tcp_host,
147145
connection->upstream->tcp_port);
148146

149-
flb_socket_close(fd);
150-
151-
return -1;
147+
flb_socket_close(fd);
148+
connection->fd = -1;
149+
connection->event.fd = -1;
150+
return -1;
152151
}
153152
flb_debug("[http_client] flb_http_client_proxy_connect connection #%i connected to %s:%i.",
154153
connection->fd,
@@ -163,7 +162,8 @@ int flb_io_net_connect(struct flb_connection *connection,
163162

164163
if (ret == -1) {
165164
flb_socket_close(fd);
166-
165+
connection->fd = -1;
166+
connection->event.fd = -1;
167167
return -1;
168168
}
169169
}

0 commit comments

Comments
 (0)