Closing a split Framed

Maybe, especially if there is a way to have a TCP FIN sent without the need of poll_shutdown. However, that does not seem to be the case when a normal Framed is split normally (as seen on wireshark). This is where CleanFramedShutdown comes to the rescue. The goal is to recombine the Sink/Stream into the Framed structure when both the wrapped Sink/Stream drop, then it calls poll_shutdown on the Framed structure

@nologik You should be able to close it on the sink half by calling SinkExt::close. If you want to discuss this further, please open a new thread.

Edit: I moved this to a new thread.

1 Like

Yes, according to a test I just ran, the TCP stream closes successfully (using SinkExt::close). Aside from requiring to be executed in an async reactor, is there a reason why SinkExt::close isn't called when a SplitSink drops?

Because close is an async method, and Drop cannot run async methods.

If it's possible to make a sync version of close (maybe signal using something similar to futures::channel::oneshot::Sender::send), that would make it easier for downstream coders

There are generally no good solutions to async drop. For example with Framed, the close call involves first flushing any data in the buffer before actually closing it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.