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> {
274
274
pin ! ( notified) ;
275
275
loop {
276
276
// 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 ( ) ;
279
281
280
282
if let Some ( data) = self . inner . borrow_mut ( ) . try_next ( cap) {
281
283
// Safety: the validity of buffer data is ensured by
@@ -284,6 +286,9 @@ impl<T: IoBufMut> FixedBufPool<T> {
284
286
return buf;
285
287
}
286
288
289
+ // Await notify_one
290
+ notified. as_mut ( ) . await ;
291
+
287
292
// It's possible that the task did not get a buffer from `try_next`.
288
293
// The `Notify` entries are created once for each requested capacity
289
294
// and never removed, so this `Notify` could have been holding
You can’t perform that action at this time.
0 commit comments