52 public function run() {
54 $startTime = microtime(
true );
57 $readSockets = $writeSockets = [];
58 foreach ( $this->clients as $clientIndex => $client ) {
59 $sockets = $client->getReadSocketsForSelect();
60 foreach ( $sockets as $i => $socket ) {
61 $readSockets[
"$clientIndex/$i"] = $socket;
63 $sockets = $client->getWriteSocketsForSelect();
64 foreach ( $sockets as $i => $socket ) {
65 $writeSockets[
"$clientIndex/$i"] = $socket;
68 if ( $readSockets === [] && $writeSockets === [] ) {
72 $exceptSockets =
null;
73 $timeout = min( $startTime + $this->timeout - microtime(
true ), 1 );
74 Wikimedia\suppressWarnings();
75 $numReady = socket_select( $readSockets, $writeSockets, $exceptSockets,
$timeout );
76 Wikimedia\restoreWarnings();
77 if ( $numReady ===
false ) {
78 wfDebugLog(
'squid', __METHOD__ .
': Error in stream_select: ' .
79 socket_strerror( socket_last_error() ) );
85 if ( microtime(
true ) - $startTime > $this->timeout * 0.99 ) {
86 wfDebugLog(
'squid', __CLASS__ .
": timeout ({$this->timeout}s)" );
88 } elseif ( !$numReady ) {
92 foreach ( $readSockets as $key => $socket ) {
93 list( $clientIndex, ) = explode(
'/', $key );
94 $client = $this->clients[$clientIndex];
97 foreach ( $writeSockets as $key => $socket ) {
98 list( $clientIndex, ) = explode(
'/', $key );
99 $client = $this->clients[$clientIndex];
104 foreach ( $this->clients as $client ) {
105 if ( !$client->isIdle() ) {
111 foreach ( $this->clients as $client ) {