public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH pxar] encoder: flush after writing last entry
Date: Wed, 24 Mar 2021 11:56:38 +0100	[thread overview]
Message-ID: <20210324105638.32493-1-d.csapak@proxmox.com> (raw)

some writers may need to be flushed to write out all data

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
for now, it is not needed because in all code paths we use it
the writers do not need to be flushed, but there is no guarantee
it will stay that way

 src/encoder/mod.rs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs
index 1004efa..c114657 100644
--- a/src/encoder/mod.rs
+++ b/src/encoder/mod.rs
@@ -83,6 +83,13 @@ async fn seq_write<T: SeqWrite + ?Sized>(
     Ok(put)
 }
 
+/// awaitable version of 'poll_flush'.
+async fn flush<T: SeqWrite + ?Sized>(
+    output: &mut T,
+) -> io::Result<()> {
+    poll_fn(|cx| unsafe { Pin::new_unchecked(&mut *output).poll_flush(cx) }).await
+}
+
 /// Write the entire contents of a buffer, handling short writes.
 async fn seq_write_all<T: SeqWrite + ?Sized>(
     output: &mut T,
@@ -715,6 +722,8 @@ impl<'a, T: SeqWrite + 'a> EncoderImpl<'a, T> {
         )
         .await?;
 
+        flush(self.output.as_mut()).await?;
+
         // done up here because of the self-borrow and to propagate
         let end_offset = self.position();
 
-- 
2.20.1





             reply	other threads:[~2021-03-24 10:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 10:56 Dominik Csapak [this message]
2021-03-29 13:22 ` Wolfgang Bumiller
2021-03-29 16:25 Dietmar Maurer
2021-03-30  6:57 Wolfgang Bumiller
2021-03-30  7:10 Dietmar Maurer
2021-03-30  7:18 Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210324105638.32493-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal