php concurrent use of test data curl_ *

When a work experience data concurrency issues, because there is no test data concurrency, when sometimes lead to poor network leading to duplication of data into the database before the line, so the use of curl_ * wrote a special function test data concurrent test case, as follows:

    function test(string $url){

        arr_ch $ = Array ();
         // Create a batch cURL handle 
        $ MH = curl_multi_init ();
         $ index = 0 ;
         the while ( $ index <20 is ) {
            
            CH $ = curl_init ();
             $ arr_ch [ $ index ] = $ CH ; 
       // url provided curl_setopt(
$arr_ch[$index], CURLOPT_URL, $url); curl_setopt ( $ arr_ch [ $ index ], CURLOPT_HEADER, 0 );
       // set the required landing sessionid curl_setopt(
$arr_ch[$index] , CURLOPT_COOKIE , "PHPSESSID=vj8qsrag5g6d2dh2t23nv03f11; qlpagecookieid=2dd06ed033d929e8cb4287c622e98275"); curl_multi_add_handle($mh , $arr_ch[$index]); $index++; } // predefined state variable $ Active = null ; // perform batch 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); } } // Close the respective handle the foreach ( $ arr_ch AS $ CH ) { curl_multi_remove_handle($mh, $ch); } curl_multi_close($mh); }

 

Guess you like

Origin www.cnblogs.com/Acsii/p/11009296.html