]> Cypherpunks.ru repositories - gostls13.git/commit
os: document and emphasize a potential misuse of File.Fd
authorChangkun Ou <hi@changkun.us>
Thu, 24 Sep 2020 06:57:00 +0000 (08:57 +0200)
committerRob Pike <r@golang.org>
Sun, 27 Sep 2020 02:23:55 +0000 (02:23 +0000)
commit7bb6fed9b53494e9846689520b41b8e679bd121d
tree261a8e4598134d06068832c7ad814ed832bed215
parent6f02578f9cff92e6c0fae4d86df01dcf99673c61
os: document and emphasize a potential misuse of File.Fd

This CL revises the document of File.Fd that explicitly points
its user to runtime.SetFinalizer where contains the information
that a file descriptor could be closed in a finalizer and therefore
causes a failure in syscall.Write if runtime.KeepAlive is not invoked.

The CL also suggests an alternative of File.Fd towards File.SyscallConn.

Fixes #41505

Change-Id: I6816f0157add48b649bf1fb793cf19dcea6894b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/256899
Reviewed-by: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
src/os/file_plan9.go
src/os/file_unix.go
src/os/file_windows.go
src/runtime/mfinal.go