Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

replicator fd leak: close the server stream on failure cases so that the tcp connection can be actually closed #240

Merged
merged 1 commit into from
Jun 30, 2017

Conversation

datoug
Copy link
Contributor

@datoug datoug commented Jun 30, 2017

as title. make sure the server calls close on failure cases.

@datoug datoug requested a review from kirg June 30, 2017 04:51

// Must close the connection on server side because closing on client side doesn't actually close the
// underlying TCP connection
inStream.Done()
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably better do a "defer inStream.Done()" immediately after the open and if-error 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.

problem is in regular cases stream is closed in the inconnection goroutine. If we do a defer, two goroutines might try to close the stream. From the websocket API the close functions are not thread-safe, also I'm not sure about the behavior of double close.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, close isn't thread-safe. i see .. i hadn't noticed that; this is fine then.


// Must close the connection on server side because closing on client side doesn't actually close the
// underlying TCP connection
inStream.Done()
Copy link
Contributor

Choose a reason for hiding this comment

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

defer inStream.Done() .. like above.


// Must close the connection on server side because closing on client side doesn't actually close the
// underlying TCP connection
inStream.Done()
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, close isn't thread-safe. i see .. i hadn't noticed that; this is fine then.

@datoug datoug merged commit 235afc9 into master Jun 30, 2017
@datoug datoug deleted the replicator_fd_leak branch June 30, 2017 06:37
datoug added a commit that referenced this pull request Jul 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants