46 public function run() {
48 $startTime = microtime(
true );
50 $readSockets = $writeSockets = [];
54 foreach ( $this->clients as $clientIndex => $client ) {
55 $sockets = $client->getReadSocketsForSelect();
56 foreach ( $sockets as $i => $socket ) {
57 $readSockets[
"$clientIndex/$i"] = $socket;
59 $sockets = $client->getWriteSocketsForSelect();
60 foreach ( $sockets as $i => $socket ) {
61 $writeSockets[
"$clientIndex/$i"] = $socket;
64 if ( !count( $readSockets ) && !count( $writeSockets ) ) {
67 $exceptSockets =
null;
68 $timeout = min( $startTime + $this->timeout - microtime(
true ), 1 );
69 Wikimedia\suppressWarnings();
70 $numReady = socket_select( $readSockets, $writeSockets, $exceptSockets,
$timeout );
71 Wikimedia\restoreWarnings();
72 if ( $numReady ===
false ) {
73 wfDebugLog(
'squid', __METHOD__ .
': Error in stream_select: ' .
74 socket_strerror( socket_last_error() ) .
"\n" );
79 if ( microtime(
true ) - $startTime > $this->timeout * 0.99 ) {
80 wfDebugLog(
'squid', __CLASS__ .
": timeout ({$this->timeout}s)\n" );
82 } elseif ( !$numReady ) {
86 foreach ( $readSockets as $key => $socket ) {
87 list( $clientIndex, ) = explode(
'/', $key );
88 $client = $this->clients[$clientIndex];
91 foreach ( $writeSockets as $key => $socket ) {
92 list( $clientIndex, ) = explode(
'/', $key );
93 $client = $this->clients[$clientIndex];
98 foreach ( $this->clients as $client ) {
99 if ( !$client->isIdle() ) {
104 foreach ( $this->clients as $client ) {