Skip to content

Keep the control connection open after a 501 reply - #607

Open
G26karthik wants to merge 1 commit into
Cloudinvoke:masterfrom
G26karthik:fix-invalid-parameter-keeps-session
Open

G26karthik wants to merge 1 commit into
Cloudinvoke:masterfrom
G26karthik:fix-invalid-parameter-keeps-session

Conversation

@G26karthik

Copy link
Copy Markdown
Contributor

When a command parameter fails to parse, the server replies 501 Invalid Parameter and then closes the control connection. For example, after REST abc the next NOOP fails because the connection is gone. handle_control_channel_error maps InvalidCommand to 501 with close_connection = false, so the session is meant to stay open.

The cause is FtpCodec::decode returning the line parser's error as the decoder error. tokio-util's Framed ends the stream after a decoder error (the next poll returns None), and the control loop reads that None as the client closing the connection.

decode now returns the parse result as the item (Item = Result<Command, ControlChanError>) and the control loop flattens it, so handle_control_channel_error decides whether to close, as it already does for other errors. I/O errors from the socket still come through the outer Result.

tests/invalid_parameter.rs sends REST abc and then NOOP over a real control connection, using the shared server from tests/common.rs. It fails on master (connection aborted on the NOOP read) and passes with the change.

FtpCodec::decode returned line parser errors as decoder errors. Framed ends the stream after a decoder error, so the control loop saw the connection as closed after sending the 501. Return the parse result as the item instead and let handle_control_channel_error decide whether to close.
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.

1 participant