forked from TrueCloudLab/frostfs-s3-gw
[#605] Fix panic when payload discard
Signed-off-by: Roman Loginov <r.loginov@yadro.com>
This commit is contained in:
parent
250538a9b4
commit
e7a8d4bdaf
3 changed files with 29 additions and 5 deletions
|
@ -525,10 +525,7 @@ func (n *Layer) objectPutAndHash(ctx context.Context, prm frostfs.PrmObjectCreat
|
|||
})
|
||||
res, err := n.frostFS.CreateObject(ctx, prm)
|
||||
if err != nil {
|
||||
if _, errDiscard := io.Copy(io.Discard, prm.Payload); errDiscard != nil {
|
||||
n.reqLogger(ctx).Warn(logs.FailedToDiscardPutPayloadProbablyGoroutineLeaks, zap.Error(errDiscard))
|
||||
}
|
||||
|
||||
n.payloadDiscard(ctx, prm.Payload)
|
||||
return nil, err
|
||||
}
|
||||
return &data.CreatedObjectInfo{
|
||||
|
@ -540,6 +537,14 @@ func (n *Layer) objectPutAndHash(ctx context.Context, prm frostfs.PrmObjectCreat
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (n *Layer) payloadDiscard(ctx context.Context, payload io.Reader) {
|
||||
if payload != nil {
|
||||
if _, errDiscard := io.Copy(io.Discard, payload); errDiscard != nil {
|
||||
n.reqLogger(ctx).Warn(logs.FailedToDiscardPutPayloadProbablyGoroutineLeaks, zap.Error(errDiscard))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type logWrapper struct {
|
||||
log *zap.Logger
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue