Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Write before poll, fix CI failures #21

Merged
merged 4 commits into from Nov 2, 2022
Merged

Conversation

mhils
Copy link
Contributor

@mhils mhils commented Nov 2, 2022

This PR fixes the CI failures over at mitmproxy/mitmproxy: https://github.com/mitmproxy/mitmproxy/actions/runs/3374019278/jobs/5599200642

The problem here is as follows:

  1. Write and Drain get batched into a single iteration.
  2. We first poll the interface (nothing to do yet) before calling sock.send
  3. We wait infinitely because we have no reason for another loop.

Previously, the following Drain would always trigger another loop. This PR changes it so that we send before polling. I need to go over this tomorrow again with a fresh mind to check if that's enough. I could imagine some weird read/flow control interactions as well which may require us to poll first, then handle sockets, and then poll again.

Copy link
Owner

@decathorpe decathorpe left a comment

Choose a reason for hiding this comment

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

Two questions / nit-picks, other than that, the changes look good. I'll push a follow-up commit to address the changed variable names.

let mut remove_conns = Vec::new();

let mut send_py_permit: Option<Permit<TransportEvent>> = None;
Copy link
Owner

Choose a reason for hiding this comment

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

Nit-pick: why send_py_permit and not py_tx_permit? The different naming scheme confused me at first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fair point. Let's change it. 👍

if send_py_permit.is_none() {
send_py_permit = self.py_tx.try_reserve().ok();
}
let can_send_net = self.net_tx.capacity() > 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Same question here: Weird name for this variable. For example, using net_tx_full and inverting the logic would be more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Happy with either! :)

@decathorpe decathorpe merged commit e4c1a96 into decathorpe:main Nov 2, 2022
@mhils mhils deleted the fix-ci branch November 2, 2022 10:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants