From bb83799bec745eb35089392865ee8b4476c3e543 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 16 Aug 2023 21:18:59 +0200 Subject: [PATCH] istream/Suspend: support buckets --- src/istream/SuspendIstream.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/istream/SuspendIstream.cxx b/src/istream/SuspendIstream.cxx index 00658679f..df32bc167 100644 --- a/src/istream/SuspendIstream.cxx +++ b/src/istream/SuspendIstream.cxx @@ -6,6 +6,7 @@ #include "ForwardIstream.hxx" #include "UnusedPtr.hxx" #include "New.hxx" +#include "Bucket.hxx" #include "event/FineTimerEvent.hxx" class SuspendIstream final : public ForwardIstream { @@ -41,6 +42,13 @@ class SuspendIstream final : public ForwardIstream { Schedule(); } + void _FillBucketList(IstreamBucketList &list) override { + if (ready) + ForwardIstream::_FillBucketList(list); + else + list.SetMore(); + } + int _AsFd() noexcept override { return ready ? ForwardIstream::_AsFd() : -1; } @@ -53,7 +61,18 @@ class SuspendIstream final : public ForwardIstream { void OnTimer() noexcept { ready = true; - input.Read(); + + switch (InvokeReady()) { + case IstreamReadyResult::OK: + break; + + case IstreamReadyResult::FALLBACK: + input.Read(); + break; + + case IstreamReadyResult::CLOSED: + break; + } } };