note 68560 added to function.curl-multi-info-read

From: Date: Tue, 01 Aug 2006 21:29:13 +0000
Subject: note 68560 added to function.curl-multi-info-read
Groups: php.notes 
Request: Send a blank email to php-notes+get-115428@lists.php.net to get a copy of this message
Currently curl_multi_info_read() is the one of the only ways to determine when a thread has finished in a multi-threaded transaction. Without it, you are forced to wait until all threads have finished before you can rest assured the data for each thread is complete. From the Zend Technology Weekly Summaries - Issue #287: "Yahoo! developer Brian J. France wrote that 'some guys at work' had created a patch implementing curl_multi_info_read() some time ago and had been running it on their servers. Should he keep it internal to Yahoo! or commit it into PHP? Extension maintainer Sterling Hughes came back from the dead to give him the go-ahead, but Brian wasn't certain which branches to commit it to at this stage. Sterling referred him to Ilia, as Release Master, who advised him to apply it to CVS HEAD for now and he'd allow it into the PHP_5_2 branch following review. It evidently passed the review; it's in there now." http://www.zend.com/zend/week/week287.php The file Brian patched is located here in the PHP CVS: http://cvs.php.net/viewvc.cgi/php-src/ext/curl/multi.c?revision=1.23 Unfortunately, my host is still using an older version of PHP and doesn't plan to upgrade. After some in-depth analysis of the libcurl documentation and experimentation, I discovered that there is one other way of detecting when an individual thread is finished in a multi-threaded transaction... When you are executing curl_multi_exec() in a loop to send/receive data, the second parameter you provide int &still_running keeps track of the number of active threads. You should already know how many threads you created, so by watching this number decrease during the transactions you can tell how many threads have finished. To identify the finished threads, you also need to be using curl_getinfo() to monitor the CURLINFO_TOTAL_TIME for each thread. You'll notice that the finished threads stop counting the CURLINFO_TOTAL_TIME because they are no longer active. So by putting two and two together, you can determine when it is appropriate to process the data received and close each thread as it finishes in a multi-threaded transaction. ---- Server IP: 216.194.113.175 Probable Submitter: 71.32.196.131 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.curl-multi-info-read.php Edit -- https://master.php.net/note/edit/68560 Del: integrated -- https://master.php.net/note/delete/68560/integrated Del: useless -- https://master.php.net/note/delete/68560/useless Del: bad code -- https://master.php.net/note/delete/68560/bad+code Del: spam -- https://master.php.net/note/delete/68560/spam Del: non-english -- https://master.php.net/note/delete/68560/non-english Del: in docs -- https://master.php.net/note/delete/68560/in+docs Del: other reasons-- https://master.php.net/note/delete/68560 Reject -- https://master.php.net/note/reject/68560 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115428) next »