|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-20 10:24 UTC] amoo_miki at yahoo dot com
Description: ------------ Trying to run multiple curl calls, fails with a timeout while checking for activity. PHP 5.3.9 and before work just fine. Test script: --------------- <?php //Taken from $ch1 = curl_init(); $ch2 = curl_init(); curl_setopt($ch1, CURLOPT_URL, "http://windows.php.net/downloads/releases/md5sum.txt"); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch2, CURLOPT_URL, "http://windows.php.net/downloads/releases/sha1sum.txt"); curl_setopt($ch2, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); $mh = curl_multi_init(); curl_multi_add_handle($mh,$ch1); curl_multi_add_handle($mh,$ch2); $active = null; do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) if (curl_multi_select($mh) != -1) do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); echo strlen(curl_multi_getcontent($ch1))."-".strlen(curl_multi_getcontent($ch2)); curl_multi_remove_handle($mh, $ch1); curl_multi_remove_handle($mh, $ch2); curl_multi_close($mh); ?> Expected result: ---------------- Seen on PHP 5.3.9: 531-1375 Actual result: -------------- Seen on PHP 5.3.10: Fatal error: Maximum execution time of 30 seconds exceeded in <filepath> on line 15 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 00:00:01 2025 UTC |
The curl details on 5.3.9 are: cURL support => enabled cURL Information => 7.21.7 Age => 3 Features AsynchDNS => Yes Debug => No GSS-Negotiate => Yes IDN => No IPv6 => Yes Largefile => Yes NTLM => Yes SPNEGO => No SSL => Yes SSPI => Yes krb4 => No libz => Yes CharConv => No Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp Host => i386-pc-win32 SSL Version => OpenSSL/0.9.8r ZLib Version => 1.2.5 libSSH Version => libssh2/1.2.7 meaning the changes are related to one of the following: 5.3.9 -> 5.3.10 libcURL: 7.21.7 -> 7.24.0 GSS/Negotiate: Yes -> NO SSPI: Yes -> No OpenSSL: 0.9.8r -> 0.9.8t libSSH: 1.2.7 -> 1.3.0 I don't see a reason for the last 2 effecting anything.No, sorry if I was unclear. The libcurl documentations says "When max_fd returns with -1, you need to wait a while and then proceed and call curl_multi_perform anyway". If you translate this in PHP (That was where I was unclear) : "When curl_multi_select returns with -1, you need to wait a while and then proceed and call curl_multi_exec anyway" Then, you should have something like this : while ($active && $mrc == CURLM_OK) { if (curl_multi_select($mh) == -1) usleep(100); do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); }Gotcha. The code change you propose works, but not sure why it doesn't make sense to me. while ($active && $mrc == CURLM_OK) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } The above piece works too, without needing the timeout, but that mean skipping the curl_multi_select altogether, practically what you found is that we can do without checking curl_multi_select which doesn't solve the problem with curl_multi_select. See where i am going? Also, thanks for looking into this. curl_multi_select is a very useful function and it would be crazy not to use it.