Skip to content
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
8 changes: 5 additions & 3 deletions bittorrent/src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ impl<'scope, 'state: 'scope> EventLoop {
break Err(Error::Io(err));
}
}
cq.sync();
if cq.overflow() > 0 {
log::error!("CQ overflow");
}
Expand Down Expand Up @@ -508,9 +507,10 @@ impl<'scope, 'state: 'scope> EventLoop {
&mut state_ref,
&mut event_tx,
);
io.sq.sync();
}

// Update right before reading the events to ensure we
// get as many as possible
cq.sync();
for cqe in &mut cq {
let io_event = RawIoEvent::from(cqe);
if let Some(event) = io.events.get_mut(io_event.event_data_idx) {
Expand Down Expand Up @@ -554,6 +554,8 @@ impl<'scope, 'state: 'scope> EventLoop {
io.read_ring.return_bid(bid);
}
}
// Update the kernel about how many we've consumed
cq.sync();

if let Some(torrent_state) = state_ref.state() {
torrent_state.handle_completed_pieces(
Expand Down
2 changes: 0 additions & 2 deletions bittorrent/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ impl<Q: SubmissionQueue> Io<Q> {
if self.sq.remaining() >= 2 {
self.sq.push(read_op);
self.sq.push(timeout_op);
// Need to sync so timeout isn't dropped prematurely?
self.sq.sync();
} else {
self.sq.push_backlog(read_op);
self.sq.push_backlog(timeout_op);
Expand Down
Loading