File tree Expand file tree Collapse file tree 1 file changed +19
-20
lines changed Expand file tree Collapse file tree 1 file changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -32,33 +32,32 @@ public function addCurls(array $curls)
32
32
return true ;
33
33
}
34
34
35
- public function exec ()
35
+ public function exec ($ selectTimeout = 1.0 )
36
36
{
37
37
if (count ($ this ->curls ) == 0 ) {
38
38
return false ;
39
39
}
40
40
41
- $ running = null ;
42
- do {
43
- usleep (10 );
44
- curl_multi_exec ($ this ->handle , $ running );
45
- } while ($ running > 0 );
41
+ // $running = null;
42
+ // do {
43
+ // usleep(100 );
44
+ // curl_multi_exec($this->handle, $running);
45
+ // } while ($running > 0);
46
46
47
47
48
- // $active = null;
49
- // do {
50
- // $mrc = curl_multi_exec($this->handle, $active);
51
- // usleep(10);
52
- // } while ($mrc == CURLM_CALL_MULTI_PERFORM);
53
- //
54
- // while ($active && $mrc == CURLM_OK) {
55
- // if (curl_multi_select($this->handle) != -1) {
56
- // do {
57
- // $mrc = curl_multi_exec($this->handle, $active);
58
- // } while ($mrc == CURLM_CALL_MULTI_PERFORM);
59
- // }
60
- // usleep(10);
61
- // }
48
+ // The first curl_multi_select often times out no matter what, but is usually required for fast transfers
49
+ $ timeout = 0.001 ;
50
+ $ active = false ;
51
+ do {
52
+ while (($ mrc = curl_multi_exec ($ this ->handle , $ active )) == CURLM_CALL_MULTI_PERFORM ) {
53
+ ;
54
+ }
55
+ if ($ active && curl_multi_select ($ this ->handle , $ timeout ) === -1 ) {
56
+ // Perform a usleep if a select returns -1: https://bugs.php.net/bug.php?id=61141
57
+ usleep (150 );
58
+ }
59
+ $ timeout = $ selectTimeout ;
60
+ } while ($ active );
62
61
63
62
$ this ->clean ();
64
63
}
You can’t perform that action at this time.
0 commit comments