ext/ftp: throw an Error when ftp_nb_fget()/ftp_nb_fput() hit a busy connection - #23540
Open
lacatoire wants to merge 2 commits into
Open
ext/ftp: throw an Error when ftp_nb_fget()/ftp_nb_fput() hit a busy connection#23540lacatoire wants to merge 2 commits into
lacatoire wants to merge 2 commits into
Conversation
Member
|
Perhaps the code should be revised to throw an Error rather than returning false. Generally, Error is used to indicate a programming mistake, and this is the case here. I believe that's more appropriate than widening the return type |
Member
|
cc @iliaal |
Member
|
Agreed, |
ftp_nb_fget() and ftp_nb_fput() answered an already busy connection with a warning and false, against a declared int return type. Reaching that guard means a transfer was started from inside another transfer, which is a programming mistake, so throw an Error instead, as ftp_close() already does on the same in_use flag. The declarations stay int. The check stays ahead of the direction and closestream writes, so the running transfer is left untouched. The test reaches the guard through a stream wrapper that calls back into the extension mid transfer.
lacatoire
force-pushed
the
fix/ftp-nb-return-types-upstream
branch
from
September 3, 2026 12:59
6a0827e to
fa921f8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reworked as suggested: the guard now throws instead of returning false, so the stub change is gone. The UPGRADING note is kept, rewritten for the new behavior — the warning and false are still going away for callers. Drop it if you would rather not carry the entry.
ftp_nb_fget()andftp_nb_fput()answered an already busy connection with a warning andfalse, against a declaredintreturn type. Reaching that guard means a transfer was started from inside another transfer — a programming mistake — so it throws anError, asftp_close()already does on the samein_useflag. Both declarations stayint.The check stays ahead of the
directionandclosestreamwrites, so the running transfer is left untouched. The test reaches the guard through a stream wrapper that calls back into the extension mid transfer, so it needs no FTP server beyond the one the ftp tests already start.ftp_nb_get()andftp_nb_put()keep their warning andfalsefor now: theirint|falseis also returned when the local file cannot be opened, so the declaration would not change. Happy to convert theirin_useguard too if you want the four consistent.