Skip to content

Commit ad28825

Browse files
committed
Fix attach.
1 parent 1481e0a commit ad28825

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/driver/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ impl Proactor {
118118
/// attached to one driver, and could only be attached once, even if you
119119
/// `try_clone` it. It will cause unexpected result to attach the handle
120120
/// with one driver and push an op to another driver.
121-
/// * io-uring: it will do nothing and return `Ok(())`.
122-
/// * polling: it will initialize the internal interest queue for the fd.
121+
/// * io-uring/polling: it will do nothing and return `Ok(())`.
123122
pub fn attach(&mut self, fd: RawFd) -> io::Result<()> {
124123
self.driver.attach(fd)
125124
}

src/driver/poll/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ impl Driver {
139139
Ok(false)
140140
} else {
141141
let need_add = !self.registry.contains_key(&arg.fd);
142-
let queue = self
143-
.registry
144-
.get_mut(&arg.fd)
145-
.expect("the fd should be attached");
142+
let queue = self.registry.entry(arg.fd).or_default();
146143
queue.push_interest(user_data, arg.interest);
147144
// We use fd as the key.
148145
let event = queue.event(arg.fd as usize);
@@ -230,8 +227,7 @@ impl Driver {
230227
Ok(())
231228
}
232229

233-
pub fn attach(&mut self, fd: RawFd) -> io::Result<()> {
234-
self.registry.entry(fd).or_default();
230+
pub fn attach(&mut self, _fd: RawFd) -> io::Result<()> {
235231
Ok(())
236232
}
237233

0 commit comments

Comments
 (0)