summaryrefslogtreecommitdiffstats
path: root/crates/driver/src/driver.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/driver/src/driver.rs')
-rw-r--r--crates/driver/src/driver.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/crates/driver/src/driver.rs b/crates/driver/src/driver.rs
index dfdd6e9..d0abbcb 100644
--- a/crates/driver/src/driver.rs
+++ b/crates/driver/src/driver.rs
@@ -349,17 +349,25 @@ impl<'ctx> Driver<'ctx> {
}
fn wait_for_task(&mut self) -> Result<()> {
- let mut pollfds: Box<[_]> = self
+ let mut pollfds: Vec<_> = self
.tasks_running
- .keys()
- .copied()
- .map(|fd| poll::PollFd::new(fd, poll::PollFlags::POLLIN))
+ .values()
+ .map(|(socket, _)| poll::PollFd::new(socket, poll::PollFlags::POLLIN))
.collect();
while poll::poll(&mut pollfds, -1).context("poll()")? == 0 {}
- for pollfd in &*pollfds {
- let events = pollfd.revents().expect("Unknown events in poll() return");
+ let pollevents: Vec<_> = pollfds
+ .into_iter()
+ .map(|pollfd| {
+ (
+ pollfd.as_fd().as_raw_fd(),
+ pollfd.revents().expect("Unknown events in poll() return"),
+ )
+ })
+ .collect();
+
+ for (fd, events) in pollevents {
if !events.contains(poll::PollFlags::POLLIN) {
if events.intersects(!poll::PollFlags::POLLIN) {
return Err(Error::new(
@@ -369,7 +377,6 @@ impl<'ctx> Driver<'ctx> {
continue;
}
- let fd = pollfd.as_raw_fd();
let (socket, task_ref) = self.tasks_running.remove(&fd).unwrap();
let task_output = Runner::result(&socket)?;