mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
fsimpl/host: fix the order of removing FD notifier
FD notifier should be removed before we close the FD, otherwise there will be race condition that another FD which has the same value is opened and added before the existing FD notifier is removed. Fixes: #3823 Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
This commit is contained in:
@@ -348,10 +348,10 @@ func (e *SCMConnectedEndpoint) Init() error {
|
||||
func (e *SCMConnectedEndpoint) Release(ctx context.Context) {
|
||||
e.DecRef(func() {
|
||||
e.mu.Lock()
|
||||
fdnotifier.RemoveFD(int32(e.fd))
|
||||
if err := syscall.Close(e.fd); err != nil {
|
||||
log.Warningf("Failed to close host fd %d: %v", err)
|
||||
}
|
||||
fdnotifier.RemoveFD(int32(e.fd))
|
||||
e.destroyLocked()
|
||||
e.mu.Unlock()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user