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

add a MemoryManager #69

Merged
merged 2 commits into from Jan 17, 2022
Merged

add a MemoryManager #69

merged 2 commits into from Jan 17, 2022

Conversation

marten-seemann
Copy link
Contributor

No description provided.

if !ok {
return
}
s.memoryManager.ReleaseMemory(int(str.recvWindow))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use a transactional scope here, but it's easy enough to just release the memory manually.

return ErrDuplicateStream
}

if s.numIncomingStreams >= s.config.MaxIncomingStreams {
// too many active streams at the same time
s.logger.Printf("[WARN] yamux: MaxIncomingStreams exceeded, forcing stream reset")
delete(s.streams, id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that at this point we haven't inserted the stream into the map yet, so this delete was not needed in the first place.

stream.go Outdated
Comment on lines 229 to 231
if err == nil && status == MemoryStatusOK {
s.recvWindow = recvWindow
_, delta = s.recvBuf.GrowTo(s.recvWindow, true)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait here we have to release memory back if it is Caution or Critical but the error is nil, as it was actually reserved!

@marten-seemann marten-seemann marked this pull request as ready for review January 11, 2022 07:43
Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually wait, as we discussed this is the wrong scope -- it is statically configured, so it is the peer scope by necessity.

@marten-seemann marten-seemann changed the title use the resource manager add a MemoryManager Jan 17, 2022
@marten-seemann marten-seemann merged commit e7b8807 into master Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants