#299: Hand a throwing fnmatch or host-key callback to the coroutine - #37
Merged
Merged
Conversation
CURLOPT_FNMATCH_FUNCTION and CURLOPT_SSH_HOSTKEYFUNCTION were the last two curl callbacks without the async exception handoff. An exception left in EG(exception) survived the remaining libcurl iterations and escaped outside the coroutine as an uncaught error, while the awaiter was woken with a cancellation. Both now store the exception on the async event with the code libcurl would have produced: the generic abort for fnmatch, which libcurl has no result code of its own for, and CURLE_PEER_FAILED_VERIFICATION for a refused host key.
The two handoff blocks overwrite the callback result, and the reason was not on the page: a warning raised as an exception reaches them with the callback's own answer already in rval. The host-key block also takes the wrong-return error above it, not only a throw from the callback.
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.
Closes true-async/php-async#299.
CURLOPT_FNMATCH_FUNCTIONandCURLOPT_SSH_HOSTKEYFUNCTIONwere the last two curl callbacks without the async exception handoff thatcurl_prereqfunction,curl_debug,curl_progressandcurl_xferinfoalready have. An exception left inEG(exception)survived the remaining libcurl iterations and escaped outside the coroutine as an uncaught fatal error, while the awaiter was woken withAsync\AsyncCancellation: Graceful shutdown.Both callbacks now store the exception on the async event with the code libcurl would have produced had the callback returned instead of thrown:
lib/ftplistparser.c,ftp_pl_insert_finfo).CURLE_PEER_FAILED_VERIFICATION, which is what libcurl reports for anything butCURLKHMATCH_OK(lib/vssh/libssh2.c).Testing
ext/async/tests/curl/072-fnmatch_exception.phpt(php-async PR) covers the fnmatch half against the FTP server fromext/ftp/tests/server.inc. Red before the change, green after; the failing diff shows both the wrong exception at the awaiter and the uncaught fatal.ext/curl/tests+ext/async/tests+ext/async/fuzzy-tests/_generated, ZTS debug, libcurl 8.12.1: 2116 passed, 0 failed.ext/curl/interface.ccompiles clean against libcurl 8.5.0 and 7.87.0.The host-key half has no test: the libcurl on the development machine carries neither
sftpnorscp, so the callback cannot be reached there.