You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// memory safety: this item in the array cannot be moved since self is borrowed, and will only be removed later by the current function
327
-
// we will access it potentially concurrently, but since we only want to detect a change in the value, that's fine
328
-
let ready = unsafe{&*(&state.receive[token].as_ref().unwrap().readyas*constbool)};
329
-
// clean up the receive table at function end, or in case the async runtime cancels this task
330
-
let finisher = Finisher::new(|| {
256
+
// this weird scope is here to prevent the rust thread checker to set this async future `!Send` just because there is remaining freed variables with `MutexGuard` type
257
+
// TODO: restore the previous code (more readable and flexible) once https://github.com/rust-lang/rust/issues/104883 is fixed
// clean up the receive table at function end, or in case the async runtime cancels this task
327
+
_finisher = Finisher::new(|| {
328
+
letmut state = self.pdu_state.lock().unwrap();
329
+
state.receive[token] = None;
330
+
state.free.push(token).unwrap();
331
+
});
332
+
333
+
break
334
+
}
335
+
}
336
+
self.received.notified().await;
337
+
}
338
+
338
339
// waiting for the answer
339
340
loop{
340
341
let notification = self.received.notified();
341
342
if*ready {break}
342
343
notification.await;
343
344
}
344
345
345
-
let state = self.pdu_state.lock().unwrap();
346
-
state.receive[token].as_ref().unwrap().answers
346
+
{
347
+
// free the token
348
+
let state = self.pdu_state.lock().unwrap();
349
+
state.receive[token].as_ref().unwrap().answers
350
+
}
347
351
}
348
352
349
353
/// trigger sending the buffered PDUs, they will be sent as soon as possible by [Self::send] instead of waiting for the frame to be full or for the timeout
0 commit comments