Skip to content
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions exporters/fluentd/src/log/fluentd_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ bool FluentdExporter::Connect() {
connected_ = socket_.connect(*addr_);
if (!connected_) {
LOG_ERROR("Unable to connect to %s", options_.endpoint.c_str());
// Close the socket to avoid leaking file descriptors on failure.
if (!socket_.invalid()) {
socket_.close();
}
connected_ = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this set of connected_ to false necessary? Seems unnecessary because it is already in false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomsonTan , thanks for pointing that out, I have removed it.
Can this be approved ?

return false;
}
}
Expand Down