Skip to content

Conversation

@asbjornst
Copy link
Contributor

When implementing advanced handlers, it is necessary to know when an upload is done, so further processing can start.

The AsyncWrite trait has 3 methods:

  • poll_write()
  • poll_flush()
  • poll_close()

Before this patch, poll_write() was called one or more times, so the writer didn't know when a transfer was complete. poll_flush() and poll_close() was never called.

This patch closes the writer upon completion, causing poll_close() to be called on the writer.

@oblique
Copy link
Owner

oblique commented Dec 1, 2025

Good point, thanks! Since we don't know if the implementor of a writer will call poll_flush from within poll_close, I think we should add flush().await before close.

When implementing advanced handlers, it is necessary
to know when an upload is done, so further processing
can start.

The AsyncWrite trait has 3 methods:
- poll_write()
- poll_flush()
- poll_close()

Before this patch, poll_write() was called one
or more times, so the writer didn't know when a
transfer was complete. poll_flush() and poll_close()
was never called.

This patch flushes and closes the writer upon completion,
causing both poll_flush() and poll_close() to be called
on the writer.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
@asbjornst
Copy link
Contributor Author

Ok, now it calls flush before close.

I my application the flush is just a no-op, as I am using it to synthesize transfers.

@oblique oblique merged commit da4f0a8 into oblique:master Dec 2, 2025
4 checks passed
@oblique
Copy link
Owner

oblique commented Dec 2, 2025

Thank you! Releasing in a bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants