m-lab / ndt-server

docker native ndt5 and ndt7 server with prometheus integration
https://www.measurementlab.net/
Apache License 2.0
99 stars 40 forks source link

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

Closed robertodauria closed 2 years ago

robertodauria commented 2 years ago

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 commented 2 years ago

Pull Request Test Coverage Report for Build 1601


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

💛 - Coveralls