-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FTP connection reuse not working in libcurl 8.12.1 #16384
Comments
Related: #16034 |
Does it work correctly without the reset done? |
I don't understand the question. How would you make multiple FTP accesses without using curl_easy_reset(), while reusing the same connection? |
Just use the same handle again? |
The program crashes in ftp.c ftp_state_quote. curl_easy_reset() is required for my use case as the FTP accesses vary a lot: file/folder creates, updates, deletes, folder traversal, lots of CURLOPT_CUSTOMREQUEST. On the other hand, not having connection reuse in libcurl is a showstopper bug. |
crashes ? That sounds like a separate bug then. Or you took away the list from under libcurl's feet. |
I have no idea. Just commenting out "curl_easy_reset" quick and dirty. The libcurl access pattern in my software FreeFileSync is complex. |
In curl 8.12 I tried to improve the logic on how we handle connections that "upgrade" to TLS later, e.g. with a STARTTLS. I found the existing code hard to read in this regard. But of course, the "improvements" blew up in my face. We fixed issues with imap, opo3, smtp in 8.12.1, but ftp was no longer reusing existing, upgraded control connections as before. This PR adds checks in our pytest FTP tests that verify reuse is happening as intended. I rewrote the logic in url.c again, so that the new test checks now pass. refs curl#16384
Thanks for the report. You pointed exactly at the location that was the problem. I added checks in out test suite, reproducing the problem, and rewrote the logic in url.c again in #16392. It would be great if you could verify that this solves your problem. Thanks. |
Yes, this works! The TLS-enabled control connection is being reused as expected! |
I'm wondering: Is FTP "AUTH TLS" considered an TLS-upgraded connection? If "yes", then adding
after
https://github.com/curl/curl/blob/2335cbaa217af072b58b87911191acac8dbc7092/lib/ftp.c#L2727C1-L2727C2 would also fix the caching bug. |
I am not aware of what the "caching bug" is, but I am on a mission to eliminate The only place left where |
I mean what this ticket is about.
Ok, cool. Either way this showstopper bug is fixed for me. So thanks a lot! |
Just pushed to #16392 and the |
Looking good! Works correctly with connection channel caching while traversing a large folder via FTP both with and without TLS enabled. |
I did this
Standard TLS-encypted connection to Apache FTP server.
Multiple FTP accesses using ::curl_easy_reset() on the same curl easy handle
=> TLS-enabled FTP control connection is not reused, see Wireshark log:

Analysis so far:
Problem is caused by:
https://github.com/icing/curl/blob/3be33a1a4777438e2ef9cca488322f789bdd40fd/lib/url.c#L955
In libcurl 8.11.1 this line was
In the 8.12.1 code
Curl_conn_is_ssl(conn, FIRSTSOCKET)
returns "true",while in 8.11.1
(conn->handler->flags&PROTOPT_SSL)
evaluated to "false".Reverting this code section back to 8.11.1 fixed FTP connection reuse in my tests.
I expected the following
FTP control connection should be reused instead of needlessly creating a new one each time
curl/libcurl version
8.12.1
operating system
Windows 10
The text was updated successfully, but these errors were encountered: