aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/control.rs23
-rw-r--r--src/ioctl.rs4
2 files changed, 24 insertions, 3 deletions
diff --git a/src/control.rs b/src/control.rs
index 0dbf6d44f..30d5d0924 100644
--- a/src/control.rs
+++ b/src/control.rs
@@ -278,10 +278,27 @@ impl<'a> Control<'a> {
278 } 278 }
279 279
280 async fn ioctl(&mut self, kind: IoctlType, cmd: u32, iface: u32, buf: &mut [u8]) -> usize { 280 async fn ioctl(&mut self, kind: IoctlType, cmd: u32, iface: u32, buf: &mut [u8]) -> usize {
281 // TODO cancel ioctl on future drop. 281 struct CancelOnDrop<'a>(&'a IoctlState);
282
283 impl CancelOnDrop<'_> {
284 fn defuse(self) {
285 core::mem::forget(self);
286 }
287 }
288
289 impl Drop for CancelOnDrop<'_> {
290 fn drop(&mut self) {
291 self.0.cancel_ioctl();
292 }
293 }
294
295 let ioctl = CancelOnDrop(self.ioctl_state);
296
297 ioctl.0.do_ioctl(kind, cmd, iface, buf).await;
298 let resp_len = ioctl.0.wait_complete().await;
299
300 ioctl.defuse();
282 301
283 self.ioctl_state.do_ioctl(kind, cmd, iface, buf).await;
284 let resp_len = self.ioctl_state.wait_complete().await;
285 resp_len 302 resp_len
286 } 303 }
287} 304}
diff --git a/src/ioctl.rs b/src/ioctl.rs
index 6a7465593..f5ab410db 100644
--- a/src/ioctl.rs
+++ b/src/ioctl.rs
@@ -88,6 +88,10 @@ impl IoctlState {
88 pending 88 pending
89 } 89 }
90 90
91 pub fn cancel_ioctl(&self) {
92 self.state.set(IoctlStateInner::Done { resp_len: 0 });
93 }
94
91 pub async fn do_ioctl(&self, kind: IoctlType, cmd: u32, iface: u32, buf: &mut [u8]) -> usize { 95 pub async fn do_ioctl(&self, kind: IoctlType, cmd: u32, iface: u32, buf: &mut [u8]) -> usize {
92 warn!("doing ioctl"); 96 warn!("doing ioctl");
93 self.state 97 self.state