storagenode/piecestore: small cleanup
* normalize ExistsCheckWorkers flag to avoid setting incorrect values * wait for limiter to finish if context was canceled Change-Id: I688a395bd958cd09233605fc264d43f91ec45ed1
This commit is contained in:
parent
1c309a0318
commit
d1d617d654
@ -213,6 +213,10 @@ func (endpoint *Endpoint) Exists(
|
||||
return &pb.ExistsResponse{}, nil
|
||||
}
|
||||
|
||||
if endpoint.config.ExistsCheckWorkers < 1 {
|
||||
endpoint.config.ExistsCheckWorkers = 1
|
||||
}
|
||||
|
||||
limiter := sync2.NewLimiter(endpoint.config.ExistsCheckWorkers)
|
||||
var mu sync.Mutex
|
||||
|
||||
@ -240,7 +244,8 @@ func (endpoint *Endpoint) Exists(
|
||||
}
|
||||
})
|
||||
if !ok {
|
||||
return &pb.ExistsResponse{}, rpcstatus.Wrap(rpcstatus.Internal, ctx.Err())
|
||||
limiter.Wait()
|
||||
return nil, rpcstatus.Wrap(rpcstatus.Canceled, ctx.Err())
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +253,7 @@ func (endpoint *Endpoint) Exists(
|
||||
|
||||
return &pb.ExistsResponse{
|
||||
Missing: missing,
|
||||
}, rpcstatus.Wrap(rpcstatus.Internal, err)
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Upload handles uploading a piece on piece store.
|
||||
|
Loading…
Reference in New Issue
Block a user