Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uds-stream: close unused sockets #243

Merged
merged 5 commits into from
May 21, 2024
Merged

uds-stream: close unused sockets #243

merged 5 commits into from
May 21, 2024

Conversation

iksaif
Copy link
Contributor

@iksaif iksaif commented May 21, 2024

We need to make sure we close the socket
file descriptors before forgetting them otherwise
we leak fds.

We need to make sure we close the socket
file descriptors before forgetting them otherwise
we leak fds.
@iksaif iksaif requested a review from a team as a code owner May 21, 2024 13:29
@@ -136,9 +136,11 @@ private void connect() throws IOException {
}
if (!delegate.connect(address)) {
if (connectionTimeout > 0 && System.nanoTime() > deadline) {
delegate.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to do this with a try/finally block? AFAICS setOption can throw too, and we'd leak then too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure how you would use a finally here 🤔 but I tried a try

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, catch makes more sense of course.

if (connectionTimeout > 0 && System.nanoTime() > deadline) {
delegate.close();
throw new IOException("Connection timed out");
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense for this block to cover setOption for connectionTimeout above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

throw new IOException("Connection timed out");
}
if (!delegate.finishConnect()) {
closeSafe(delegate);
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 call redundant with the catch block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@@ -1,5 +1,6 @@
package com.timgroup.statsd;

import java.net.SocketOption;
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@iksaif
Copy link
Contributor Author

iksaif commented May 21, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented May 21, 2024

🚂 MergeQueue

Pull request added to the queue.

This build is going to start soon! (estimated merge in less than 0s)

Use /merge -c to cancel this operation!

@dd-devflow
Copy link

dd-devflow bot commented May 21, 2024

❌ MergeQueue

Build pipeline was skipped for a632aa8

This could indicate an error in the configuration of your build pipeline.

Details

gitlab pipeline was skipped link

If you need support, contact us on Slack #devflow with those details!

@iksaif iksaif merged commit f9b0644 into master May 21, 2024
12 of 13 checks passed
@iksaif iksaif deleted the corentin.chary/unix-stream branch May 21, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants