You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying to use this crate to write a zip compressed stream to a tokio::DuplexStream. This currently fails because DuplexStream implements poll_shutdown by not allowing any more writes to the stream. This is problematic as calling close on the ZipFileWriter calls shutdown() to finalize the compression encoder for each file added to the archive, which means that writes after the first call to close all fail.
I don't think DuplexStream is wrong here to not allow writes after being shutdown, the Tokio documentation for Shutdown() on the AsyncWrite trait mentions that after shutdown succeeds, "the I/O object itself is likely no longer usable." (https://docs.rs/tokio-io/0.1.13/tokio_io/trait.AsyncWrite.html#return-value)
From what I can tell, Shutdown is called here so that the async_compression encoder can finalize the encoding. I guess this is mostly OK for that use case (though I see someone has raised an issue about adding another way of finalizing - Nullus157/async-compression#141) but in this case it seems like it will stop this library working at all.
Would be happy to help out with a fix but thought I'd raise this before trying anything in case there's a better way of going about what I'm trying to do. I'm not sure if this problem should/could be fixed/worked-around in this crate, or if a change needs to be implemented in async_compression to allow finalizing the encoder without shutting down the writer first.
The text was updated successfully, but these errors were encountered:
I've gone ahead and committed a quick workaround as per the other issue which ignores the shutdown() call internally. This indirection obviously isn't ideal though so I definitely want to push for an additional API with async_compression as per the issue you linked above.
Thank you for looking into this nonetheless - let me know if you still run into any problems with this.
First of all, thanks for the great crate!!
I'm currently trying to use this crate to write a zip compressed stream to a tokio::DuplexStream. This currently fails because
DuplexStream
implementspoll_shutdown
by not allowing any more writes to the stream. This is problematic as callingclose
on theZipFileWriter
callsshutdown()
to finalize the compression encoder for each file added to the archive, which means that writes after the first call toclose
all fail.I don't think
DuplexStream
is wrong here to not allow writes after being shutdown, the Tokio documentation forShutdown()
on theAsyncWrite
trait mentions that after shutdown succeeds, "the I/O object itself is likely no longer usable." (https://docs.rs/tokio-io/0.1.13/tokio_io/trait.AsyncWrite.html#return-value)From what I can tell,
Shutdown
is called here so that the async_compression encoder can finalize the encoding. I guess this is mostly OK for that use case (though I see someone has raised an issue about adding another way of finalizing - Nullus157/async-compression#141) but in this case it seems like it will stop this library working at all.I guess it's fortunate that the
tokio::File
andtokio::Cursor<Vec<u8>>
implementations ofshutdown
just callflush
(https://github.com/tokio-rs/tokio/blob/702d6dccc948b6a460caa52da4e4c03b252c5c3b/tokio/src/fs/file.rs#L702 and https://github.com/tokio-rs/tokio/blob/702d6dccc948b6a460caa52da4e4c03b252c5c3b/tokio/src/io/async_write.rs#L376) so it's not so much of an issue for those two writers (at least for now, maybe the implementations will change in the future to actually shut down?).For the time being I've worked around this by wrapping
DuplexStream
to do a flush instead of a shutdown, but it's not ideal:Would be happy to help out with a fix but thought I'd raise this before trying anything in case there's a better way of going about what I'm trying to do. I'm not sure if this problem should/could be fixed/worked-around in this crate, or if a change needs to be implemented in async_compression to allow finalizing the encoder without shutting down the writer first.
The text was updated successfully, but these errors were encountered: