https://bugs.kde.org/show_bug.cgi?id=512354
--- Comment #2 from nyanpasu64 <[email protected]> --- Looking at the top-level FtpInternal::listDir call, it turns out the `ftpOpenConnection(LoginMode::Implicit)` check passes because KIO still thinks the connection is open from earlier. So when the code falls through to `ftpOpenDir > ftpOpenCommand > ftpOpenDataConnection`, it attempts `ftpOpenPASVDataConnection`, which fails and takes down the command socket as well as data. It then calls `ftpOpenEPSVDataConnection` which assumes the command socket is open. We need to early-exit if the command socket has been closed. (Sidenote: When the command socket is dead, it's actually `ftpOpenPASVDataConnection > ftpSendCmd` that closes the dead socket while "transparently" reconnecting (which is a lie, see Bug 529174 where it loses the cwd). If we set ftpSendCmd(maxretries) to 0, nobody calls `FtpInternal::closeConnection()` to close the dead socket, and all further F5 attempts return an error!) To fix this issue, I had to change `ftpOpenDataConnection`, `ftpOpenDir`, and `listDir` to early-exit if the command socket dies, instead of trying alternative command paths (which assume an open connection). Even so, Dolphin shows an "Internal Error\n Please send a full bug report at https://bugs.kde.org" error when a connection fails, because `ftpOpenPASVDataConnection` assumes its error code would never be used, while `ftpOpenDataConnection > ftpOpenPASVDataConnection` now returns the callee's error code (and the existing code already did if opening a data connection failed without crashing). And we can't just make `ftpOpenPASVDataConnection` return error information, because `ftpOpenPASVDataConnection > ftpSendCmd` attempts reconnection, and if it fails returns a bool (which can't be easily changed with dozens of callers). At this point I believe the easiest fix for error handling issues in KIO is to exit the program upon any disconnection, and a proper fix would be to close the command socket (without attempting reconnection) upon errors, respond to a closed command socket by early-exiting (as I have done), and handle reconnection logic in the top-level methods. My idea is to place reconnect logic in Ftp::method(), but this goes against the code comment of "This class should not contain *any* FTP logic". But I don't particularly like the alternative of placing it in FtpInternal::method() either, because there's no guarantee that methods won't call each other with each layer conducting its own retry logic. (outline panel time...) I do think this approach could be made workable by constructing (stack-allocated?) a RetryMonitor object (noncopyable int wrapper?) in Ftp and passing references to top-level FtpInternal methods (and when eg. FtpInternal::stat() recurses, pass it to the child call). Though I suspect we really should keep a *set* of seen URLs rather than recursing, and abort upon a cycle or ~16 links, rather than overflowing the stack? I'm not sure which other FtpInternal methods call other entry points. I haven't looked into REST (data reconnect) handling, but would not be surprised if it's broken too right now. -- You are receiving this mail because: You are watching all bug changes.
