46 public function run() {
48 $startTime = microtime(
true );
51 $readSockets = $writeSockets = [];
52 foreach ( $this->clients as $clientIndex => $client ) {
53 $sockets = $client->getReadSocketsForSelect();
54 foreach ( $sockets as $i => $socket ) {
55 $readSockets[
"$clientIndex/$i"] = $socket;
57 $sockets = $client->getWriteSocketsForSelect();
58 foreach ( $sockets as $i => $socket ) {
59 $writeSockets[
"$clientIndex/$i"] = $socket;
62 if ( $readSockets === [] && $writeSockets === [] ) {
66 $exceptSockets =
null;
67 $timeout = min( $startTime + $this->timeout - microtime(
true ), 1 );
68 Wikimedia\suppressWarnings();
69 $numReady = socket_select( $readSockets, $writeSockets, $exceptSockets,
$timeout );
70 Wikimedia\restoreWarnings();
71 if ( $numReady ===
false ) {
72 wfDebugLog(
'squid', __METHOD__ .
': Error in stream_select: ' .
73 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() ) {
105 foreach ( $this->clients as $client ) {