Skip to content

Commit 2bb580a

Browse files
authored
fix(driver,iour): resubmit poll op (#462)
1 parent 414fd77 commit 2bb580a

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

compio-driver/src/iour/mod.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub(crate) struct Driver {
8585
pool_completed: Arc<SegQueue<Entry>>,
8686
#[cfg(io_uring)]
8787
buffer_group_ids: Slab<()>,
88+
need_push_notifier: bool,
8889
}
8990

9091
impl Driver {
@@ -106,32 +107,20 @@ impl Driver {
106107
io_uring_builder.setup_taskrun_flag();
107108
}
108109

109-
let mut inner = io_uring_builder.build(builder.capacity)?;
110+
let inner = io_uring_builder.build(builder.capacity)?;
110111

111112
if let Some(fd) = builder.eventfd {
112113
inner.submitter().register_eventfd(fd)?;
113114
}
114115

115-
#[allow(clippy::useless_conversion)]
116-
unsafe {
117-
inner
118-
.submission()
119-
.push(
120-
&PollAdd::new(Fd(notifier.as_raw_fd()), libc::POLLIN as _)
121-
.multi(true)
122-
.build()
123-
.user_data(Self::NOTIFY)
124-
.into(),
125-
)
126-
.expect("the squeue sould not be full");
127-
}
128116
Ok(Self {
129117
inner,
130118
notifier,
131119
pool: builder.create_or_get_thread_pool(),
132120
pool_completed: Arc::new(SegQueue::new()),
133121
#[cfg(io_uring)]
134122
buffer_group_ids: Slab::new(),
123+
need_push_notifier: true,
135124
})
136125
}
137126

@@ -196,7 +185,9 @@ impl Driver {
196185
Self::CANCEL => {}
197186
Self::NOTIFY => {
198187
let flags = entry.flags();
199-
debug_assert!(more(flags));
188+
if !more(flags) {
189+
self.need_push_notifier = true;
190+
}
200191
self.notifier.clear().expect("cannot clear notifier");
201192
}
202193
_ => unsafe {
@@ -306,6 +297,18 @@ impl Driver {
306297
// Anyway we need to submit once, no matter there are entries in squeue.
307298
trace!("start polling");
308299

300+
if self.need_push_notifier {
301+
#[allow(clippy::useless_conversion)]
302+
self.push_raw(
303+
PollAdd::new(Fd(self.notifier.as_raw_fd()), libc::POLLIN as _)
304+
.multi(true)
305+
.build()
306+
.user_data(Self::NOTIFY)
307+
.into(),
308+
)?;
309+
self.need_push_notifier = false;
310+
}
311+
309312
if !self.poll_entries() {
310313
self.submit_auto(timeout)?;
311314
self.poll_entries();

0 commit comments

Comments
 (0)