-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
only close curl handle if it's done #2892
Conversation
if a handle happens to create another message than "done", then we shouldn't remove the handle yet, right? notably, there are no other message types in upstream libcurl *yet*, but this will help future-proof Guzzle so 2021 versions of Guzzle may run better on future versions of libcurl.
the the rest of the code is doing the same, ref `\CURLM_CALL_MULTI_PERFORM`
Thank you for this PR. It cannot be merged without tests. Please add some. |
@Nyholm don't think that's currently possible with stock libcurl. the msg member states what kind of message this is, and currently the member only exist to make sure curl_multi_info_read() can return other types of messages in the future without breaking the C api. however, for the time being, the only message type that exist is the CURLMSG_DONE message (ref https://curl.se/libcurl/c/curl_multi_info_read.html ), // curl_multi_info_read wrapper which also returns a fake message to test if other code correctly handles
// a message where ["msg"] !== CURLMSG_DONE
function curl_multi_info_read_with_fake_test_data($multi_handle, int &$queued_messages = null){
static $has_delivered_fake_message = false;
if(!$has_delivered_fake_message){
$has_delivered_fake_message = true;
$queued_messages = 1; //
return array(
'msg'=>CURLMSG_DONE + 1, // << fake message id, does not exist in libcurl (yet?)
'result' => CURLM_INTERNAL_ERROR, // << can be anything, just a fake test message
'handle' => null, // << ??
);
}
return curl_multi_info_read($multi_handle, $queued_messages);
} though.. however, if Guzzle waits until libcurl actually starts returning other messages than CURLMSG_DONE before adding code to handle it, then Guzlle will just randomly start breaking one day because Guzzle treats all messages as if it was a CURLMSG_DONE message, even when it isn't... |
I'm hesitant to merge this since there's no example where this is broken, and there are no tests. Please feel free to open a new PR if you feel strongly differently. Guzzle is very widely used, and we have to be very careful not to break things for people. :) |
Can I object to the closing of this PR? I'm the main author of libcurl and I wrote this API. It is clearly documented to return a |
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpClient] Double check if handle is complete | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | This is a forward compatibility fix. We did the same in Guzzle after a comment from bagder. guzzle/guzzle#2892 (comment) Basically, if libcurl decides to add an other value for `msg`, then our code will break without this PR. The only value for `msg` with current latest version of curl is `CURLMSG_DONE` which means that this is not a bugfix yet.. but it make sure that we respect the libcurl API. Commits ------- f35a6ad [HttpClient] Double check if handle is complete
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpClient] Double check if handle is complete | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | This is a forward compatibility fix. We did the same in Guzzle after a comment from bagder. guzzle/guzzle#2892 (comment) Basically, if libcurl decides to add an other value for `msg`, then our code will break without this PR. The only value for `msg` with current latest version of curl is `CURLMSG_DONE` which means that this is not a bugfix yet.. but it make sure that we respect the libcurl API. Commits ------- f35a6ad77e [HttpClient] Double check if handle is complete
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpClient] Double check if handle is complete | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | This is a forward compatibility fix. We did the same in Guzzle after a comment from bagder. guzzle/guzzle#2892 (comment) Basically, if libcurl decides to add an other value for `msg`, then our code will break without this PR. The only value for `msg` with current latest version of curl is `CURLMSG_DONE` which means that this is not a bugfix yet.. but it make sure that we respect the libcurl API. Commits ------- f35a6ad77e [HttpClient] Double check if handle is complete
if a handle happens to create another message than "done", then we shouldn't remove the handle yet, right?
notably, there are no other message types in upstream libcurl yet,
but this will help future-proof Guzzle so 2021 versions of Guzzle may run better on future versions of libcurl.