Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAAS-32009: add defer to all ctx.Ascend() calls in realm #125

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions array.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@
}

func toIdx(v valueInt) uint32 {
if v >= 0 && v < math.MaxUint32 {

Check failure on line 562 in array.go

View workflow job for this annotation

GitHub Actions / test (1.16.x, ubuntu-latest, 386)

constant 4294967295 overflows valueInt
return uint32(v)
}
return math.MaxUint32
Expand Down Expand Up @@ -623,6 +623,7 @@
if err := ctx.Descend(); err != nil {
return memUsage, err
}
defer ctx.Ascend()

if ctx.ArrayLenExceedsThreshold == nil {
return memUsage, errArrayLenExceedsThresholdNil
Expand All @@ -640,7 +641,6 @@
return memUsage, err
}

ctx.Ascend()
zhouselena marked this conversation as resolved.
Show resolved Hide resolved
return memUsage, nil
}

Expand All @@ -661,6 +661,5 @@
}
}

ctx.Ascend()
return memUsage, nil
}
4 changes: 1 addition & 3 deletions array_sparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ func (a *sparseArrayObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err
if err := ctx.Descend(); err != nil {
return SizeEmptyStruct, err
}
defer ctx.Ascend()

// sparseArrayObject overhead
memUsage = SizeEmptyStruct
Expand All @@ -552,7 +553,6 @@ func (a *sparseArrayObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err
return memUsage, err
}

ctx.Ascend()
return memUsage, nil
}

Expand All @@ -571,7 +571,5 @@ func (a *sparseArrayObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err
}
}

ctx.Ascend()

return memUsage, err
}
3 changes: 1 addition & 2 deletions builtin_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (mo *mapObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error)
if err := ctx.Descend(); err != nil {
return memUsage, err
}
defer ctx.Ascend()

memUsage, err = mo.baseObject.MemUsage(ctx)
if err != nil {
Expand Down Expand Up @@ -176,8 +177,6 @@ func (mo *mapObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error)
}
}

ctx.Ascend()

return memUsage, nil
}

Expand Down
3 changes: 1 addition & 2 deletions builtin_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ func (so *setObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error)
if err := ctx.Descend(); err != nil {
return memUsage, err
}
defer ctx.Ascend()

memUsage, err = so.baseObject.MemUsage(ctx)
if err != nil {
Expand Down Expand Up @@ -434,7 +435,5 @@ func (so *setObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error)
}
}

ctx.Ascend()

return memUsage, nil
}
3 changes: 1 addition & 2 deletions object.go
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,7 @@ func (o *baseObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error)
if err := ctx.Descend(); err != nil {
return 0, err
}
defer ctx.Ascend()

memUsage = SizeEmptyStruct
if ctx.ObjectPropsLenExceedsThreshold(len(o.propNames)) {
Expand Down Expand Up @@ -1981,8 +1982,6 @@ func (o *baseObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error)
}
}

ctx.Ascend()

return memUsage, nil
}

Expand Down
3 changes: 1 addition & 2 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ func (p *proxyObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error
if err := ctx.Descend(); err != nil {
return 0, err
}
defer ctx.Ascend()

memUsage = SizeEmptyStruct
inc, err := p.baseObject.MemUsage(ctx)
Expand All @@ -1087,8 +1088,6 @@ func (p *proxyObject) MemUsage(ctx *MemUsageContext) (memUsage uint64, err error
}
}

ctx.Ascend()

return memUsage, nil
}

Expand Down
Loading