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

Suppress writes triggered by EOF reads #318

Open
Lukasa opened this issue Dec 1, 2021 · 0 comments
Open

Suppress writes triggered by EOF reads #318

Lukasa opened this issue Dec 1, 2021 · 0 comments

Comments

@Lukasa
Copy link
Contributor

Lukasa commented Dec 1, 2021

When a child channel is "closed while open", we deliver any pending reads into the Channel:

if self.pendingReads.count > 0 && self._isActive {
self.unsatisfiedRead = false
self.deliverPendingReads()
}

After that, we actually close the stream:

if let reason = reason {
// To receive from the network, it must be safe to force-unwrap here.
let err = NIOHTTP2Errors.streamClosed(streamID: self.streamID!, errorCode: reason)
self.errorEncountered(error: err)
} else {
self.closedCleanly()
}

The problem with this is that these reads may trigger some writes. Those writes are doomed to fail, but we let them run into the parent channel before they fail. We could fail them faster by making the stream channel state a little more complex. This will also prevent errors triggered by these writes from having to propagate through the parent channel, which can trigger weird follow-on issues.

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

No branches or pull requests

1 participant