Fix UDS bind cause fd leak in gofer
After the finalizer optimize in 76039f8959
commit, clientFile needs to closed before finalizer release it.
The clientFile is not closed if it is created via
gofer.(*inodeOperations).Bind, this will cause fd leak which is hold
by gofer process.
Fixes #1396
Signed-off-by: Yong He <chenglang.hy@antfin.com>
Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
This commit is contained in:
parent
6b42453039
commit
8a46e83111
|
@ -234,6 +234,8 @@ func (i *inodeOperations) Bind(ctx context.Context, dir *fs.Inode, name string,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// We're not going to use newFile after return.
|
||||||
|
defer newFile.close(ctx)
|
||||||
|
|
||||||
// Stabilize the endpoint map while creation is in progress.
|
// Stabilize the endpoint map while creation is in progress.
|
||||||
unlock := i.session().endpoints.lock()
|
unlock := i.session().endpoints.lock()
|
||||||
|
@ -254,7 +256,6 @@ func (i *inodeOperations) Bind(ctx context.Context, dir *fs.Inode, name string,
|
||||||
// Get the attributes of the file to create inode key.
|
// Get the attributes of the file to create inode key.
|
||||||
qid, mask, attr, err := getattr(ctx, newFile)
|
qid, mask, attr, err := getattr(ctx, newFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newFile.close(ctx)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +271,6 @@ func (i *inodeOperations) Bind(ctx context.Context, dir *fs.Inode, name string,
|
||||||
// cloned and re-opened multiple times after creation.
|
// cloned and re-opened multiple times after creation.
|
||||||
_, unopened, err := i.fileState.file.walk(ctx, []string{name})
|
_, unopened, err := i.fileState.file.walk(ctx, []string{name})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newFile.close(ctx)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue