Skip to content

Make http1Connections and http2Connections non-optional #482

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

Closed

Conversation

dnadoba
Copy link
Collaborator

@dnadoba dnadoba commented Nov 19, 2021

Follow up from #481 (comment)

case .removeConnection:
return true
if index < initialOverflowIndex {
self.overflowIndex = self.connections.index(before: self.overflowIndex)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previously we didn't update self.overflowIndex correctly which did hide some bugs because we rarely reused HTTP1Connections ever again after migration.

Copy link
Member

Choose a reason for hiding this comment

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

Would love to have a comment like this here:

// If the connection has an index smaller than the previous overflow index, we deal with
// a general purpose connection. For this reason we need to decrement the overflow index.

Great catch!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also added to .shutdown() from where I have borrowed this code snippet.

Copy link
Member

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

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

Okay, I agree this makes the code nicer. Thanks for pushing for this. However we should go a little further.

case .removeConnection:
return true
if index < initialOverflowIndex {
self.overflowIndex = self.connections.index(before: self.overflowIndex)
Copy link
Member

Choose a reason for hiding this comment

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

Would love to have a comment like this here:

// If the connection has an index smaller than the previous overflow index, we deal with
// a general purpose connection. For this reason we need to decrement the overflow index.

Great catch!

@@ -523,7 +515,7 @@ extension HTTPConnectionPool {
// Connections report events back to us, if they are in a shutdown that was
// initiated by the state machine. For this reason this callback might be invoked
// even though all references to HTTP2Connections have already been cleared.
_ = self.http2Connections?.newHTTP2MaxConcurrentStreamsReceived(connectionID, newMaxStreams: newMaxStreams)
_ = self.http2Connections.newHTTP2MaxConcurrentStreamsReceived(connectionID, newMaxStreams: newMaxStreams)
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment above.

@@ -532,26 +524,20 @@ extension HTTPConnectionPool {
// Connections report events back to us, if they are in a shutdown that was
// initiated by the state machine. For this reason this callback might be invoked
// even though all references to HTTP2Connections have already been cleared.
_ = self.http2Connections?.goAwayReceived(connectionID)
_ = self.http2Connections.goAwayReceived(connectionID)
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment above.

Comment on lines +51 to +54
self.http1Connections = HTTP1Connections(
maximumConcurrentConnections: maximumConcurrentHTTP1Connections,
generator: idGenerator
)
Copy link
Member

Choose a reason for hiding this comment

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

I bet we reserve an array within this initializer. Maybe we want to add another initializer here, that really creates an empty HTTP1Connections. The struct is replaced in the migration anyway.

The constructor should set maximumConcurrentConnections to a default value. Then we don't need to pass it in the HTTP2 constructor.

@dnadoba
Copy link
Collaborator Author

dnadoba commented Nov 19, 2021

Delayed until #487 is fixed.
Bug fix extracted into #486

@dnadoba dnadoba closed this Nov 19, 2021
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.

2 participants