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

Replace calls to Fd() with syscall.RawConn.Control() #371

Merged
merged 3 commits into from
Aug 16, 2022

Conversation

robertodauria
Copy link
Contributor

@robertodauria robertodauria commented Aug 15, 2022

Fd() removes the O_NONBLOCK flag from the descriptor before returning it.

From os/file_unix.go:

	// If we put the file descriptor into nonblocking mode,
	// then set it to blocking mode before we return it,
	// because historically we have always returned a descriptor
	// opened in blocking mode. The File will continue to work,
	// but any blocking operation will tie up a thread.

When Fd() is called on a *os.File obtained via conn.File(), this descriptor is actually a duplicate but the underlying socket is shared. The end result is that the original conn still thinks it has a non-blocking socket, while the socket actually became blocking. This causes things like conn.Close() blocking forever if no data is received.

This should actually resolve #361 .


This change is Reviewable

@coveralls
Copy link
Collaborator

coveralls commented Aug 15, 2022

Pull Request Test Coverage Report for Build 1601

  • 39 of 53 (73.58%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 81.587%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tcpinfox/tcpinfox_linux.go 15 19 78.95%
bbr/bbr_linux.go 24 34 70.59%
Totals Coverage Status
Change from base Build 1597: -0.3%
Covered Lines: 1799
Relevant Lines: 2205

💛 - Coveralls

Copy link
Contributor

@stephen-soltesz stephen-soltesz left a comment

Choose a reason for hiding this comment

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

:lgtm: - Thank you!

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained

@robertodauria robertodauria merged commit 0823c17 into main Aug 16, 2022
@robertodauria robertodauria deleted the sandbox-roberto-remove-fd-calls branch August 16, 2022 13:06
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.

ndt7: goroutine leak at the end of a measurement
3 participants