connection shutdown, basics and first use#13904
Conversation
This adds connection shutdown infrastructure and first use
for FTP. FTP data connections, when not encountering an error,
are now shut down in a blocking way with a 2sec timeout.
- add cfilter `Curl_cft_shutdown` callback
- keep a shutdown start timestamp and timeout at connectdata
- provide shutdown timeout default and member in
`data->set.shutdowntimeout`.
- provide methods for starting, interrogating and clearing
shutdown timers
- provide `Curl_conn_shutdown_blocking()` to shutdown the
`sockindex` filter chain in a blocking way. Use that in FTP.
- add `Curl_conn_cf_poll()` to wait for socket events during
shutdown of a connection filter chain.
This gets the monitoring sockets and events via the filters
"adjust_pollset()" methods. This gives correct behaviour when
shutting down a TLS connection through a HTTP/2 proxy.
- Implement shutdown for all socket filters
- for HTTP/2 and h2 proxying to send GOAWAY
- for TLS backends to the best of their capabilities
- for tcp socket filter to make a final, nonblocking
receive to avoid unwanted RST states
- add shutdown forwarding to happy eyeballers and
https connect ballers when applicable.
bagder
left a comment
There was a problem hiding this comment.
It looks good. Just some questions!
| } | ||
|
|
||
| timediff_t Curl_shutdown_timeleft(struct connectdata *conn, int sockindex, | ||
| struct curltime *nowp) |
There was a problem hiding this comment.
This function is used in two places, both of them set nowp to NULL. Do you really need this argument?
There was a problem hiding this comment.
I thought I follow the spirit of Curl_timeleft(). Shoudl we remove it there as well?
There was a problem hiding this comment.
In Curl_timeleft's case there are several callers that use the argument so there it does save a few calls to Curl_now().
| } | ||
|
|
||
| void Curl_shutdown_start(struct Curl_easy *data, int sockindex, | ||
| struct curltime *nowp) |
There was a problem hiding this comment.
This function is used in two places, both of them set nowp to NULL. Do you really need this argument?
| } | ||
| } | ||
|
|
||
| CURLcode Curl_conn_shutdown_blocking(struct Curl_easy *data, int sockindex) |
There was a problem hiding this comment.
This risks blocking the multi interface for the entire timeout period (DEFAULT_SHUTDOWN_TIMEOUT_MS) when the FTPS data connection is closed. Do you plan to add handling of this in a non-blocking way in a follow-up change?
There was a problem hiding this comment.
To have a non-blocking shutdown of the data connection would be nice, indeed. That would require some more radical change in the FTP code, I guess.
For now, the blocking way at least assures that the FTP data connection works. We have multiple reports that at least uploads fail regularly if we do not do this, as FTP servers have become more sensitive to a clean TLS shutdown.
The change in this PR is a bugfix at the expense of parallel performance.
Note that the same concerns apply to the connect phase of FTP data connection where we do a blocking connect.
There was a problem hiding this comment.
Yeah. Let's merge this as it fixes issues, and maybe work on improving it further later on.
|
Could it be that this PR breaks FTP uploads with a POSTQUOTE? cc @icing |
|
@rmja If you could produce a debug trace with |
Follow-up to c31041b curl#13904 Closes curl#16103
This adds connection shutdown infrastructure and first use for FTP. FTP data connections, when not encountering an error, are now shut down in a blocking way with a 2sec timeout.
Curl_cft_shutdowncallbackdata->set.shutdowntimeout.Curl_conn_shutdown_blocking()to shutdown thesockindexfilter chain in a blocking way. Use that in FTP.Curl_conn_cf_poll()to wait for socket events duringshutdown of a connection filter chain.
This gets the monitoring sockets and events via the filters
"adjust_pollset()" methods. This gives correct behaviour when
shutting down a TLS connection through a HTTP/2 proxy.
Test coverage of the FTP blocking shutdown of its data connection is covered in
test_30_5andtest_31_05ftp upload tests.Update: removed known bugs 7.5 and 7.11 fixed by this PR. Verified by local upload tests with
vsftpdand confirmation on #13556.