cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Active FTP failures while lacking available file handles

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 29 Nov 2011 13:12:58 +0100 (CET)

On Tue, 29 Nov 2011, Gokhan Sengun wrote:

> FTP server could not appreciate the failure in opening the data connection,
> therefore sending file content (of course it gets a RST from the client), it
> also sends "226 Transfer OK" from ctrl connection. Or FTP server appreciates
> the failure and sends "421 xxx" regarding the failure.
>
> Since curl does not read the "last" message from the control connection

Right, that is what bug #3429299 basically is about. I've had a look, and an
annoying detail is that Curl_socket_ready() currently can't wait for READ on
two sockets simultaneously so it needs to be modified somehow first. Then of
course we need to implement code that actually acts when the control
connection gets data when libcurl expects the data connection to connect.

> in an attempt to connect again to the same server next time and reuse the
> connection, "SocketIsDead" function concludes that the control connection is
> dead, however it is still there and pretty much fine. That is because "poll"
> sees that read flag is set.

Yes and that is correct, as there is data on the connection that was never
read so a reconnected connection would then suddenly get data from the
previous request and that is BAD.

> I think this is wrong and it needs to be more clever but this is a different
> story and not easy to implement in a platform independent manner!

No it isn't wrong. What makes you say it is wrong?

What needs to be fixed is to make sure that there is no pending data from the
previous request. Your case is one of the reasons why the check is there!

> In order to prevent that from happening, I introduced the fix given below
> and it seemed to fix the issue for me.

Since you didn't properly read out the control channel before the previous
connection returned failure, you cannot guarantee the state and you're
guessing and making assumptions that we cannot accept as a generic solution.

When it comes to connection re-use is is MUCH better to play safe and not
re-use if there's any doubt and only re-use when things are sure to be fine.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-11-29