File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -274,8 +274,10 @@ impl<T: IoBufMut> FixedBufPool<T> {
274274 pin ! ( notified) ;
275275 loop {
276276 // In the single-threaded case, no buffers could get checked in
277- // between us calling `try_next` and here, so we can't miss a wakeup.
278- notified. as_mut ( ) . await ;
277+ // between us calling `try_next` and here. However, we may still miss a wake-up,
278+ // as multiple check-ins can occur before any waking tasks are scheduled,
279+ // which would result in the loss of a permit
280+ notified. as_mut ( ) . enable ( ) ;
279281
280282 if let Some ( data) = self . inner . borrow_mut ( ) . try_next ( cap) {
281283 // Safety: the validity of buffer data is ensured by
@@ -284,6 +286,9 @@ impl<T: IoBufMut> FixedBufPool<T> {
284286 return buf;
285287 }
286288
289+ // Await notify_one
290+ notified. as_mut ( ) . await ;
291+
287292 // It's possible that the task did not get a buffer from `try_next`.
288293 // The `Notify` entries are created once for each requested capacity
289294 // and never removed, so this `Notify` could have been holding
You can’t perform that action at this time.
0 commit comments