Change Intent
Add a .close() method to ResourceHandle that frees the file descriptor that the ResourceHandle is managing.
Justification
The current design of ResourceHandle is racy because it allows a file descriptor to be sent over a Unix Domain Socket without ensuring that the file descriptor is still open. It also allows a file descriptor to be recovered into a RandomAccessFile, Socket, etc. without ensuring that the file descriptor is valid.
https://dart-review.googlesource.com/c/sdk/+/428905 fixes those lifetime issues by duplicating input file descriptors. It frees them using a finalizer but a .close() method will ensure that those file descriptors are closed promptly.
ImpactThis change will break anyone who
implements ResourceHandle without implementing
noSuchMethod. On GitHub, no such usages exist.
MitigationDevelopers must modify all classes that
implements ResourceHandle without implementing
noSuchMethod.