MediaWiki REL1_33
SquidPurgeClientPool.php
Go to the documentation of this file.
1<?php
24 protected $clients = [];
25
27 protected $timeout = 5;
28
32 function __construct( $options = [] ) {
33 if ( isset( $options['timeout'] ) ) {
34 $this->timeout = $options['timeout'];
35 }
36 }
37
42 public function addClient( $client ) {
43 $this->clients[] = $client;
44 }
45
46 public function run() {
47 $done = false;
48 $startTime = microtime( true );
49
50 while ( !$done ) {
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;
56 }
57 $sockets = $client->getWriteSocketsForSelect();
58 foreach ( $sockets as $i => $socket ) {
59 $writeSockets["$clientIndex/$i"] = $socket;
60 }
61 }
62 if ( $readSockets === [] && $writeSockets === [] ) {
63 break;
64 }
65
66 $exceptSockets = null;
67 $timeout = min( $startTime + $this->timeout - microtime( true ), 1 );
69 $numReady = socket_select( $readSockets, $writeSockets, $exceptSockets, $timeout );
71 if ( $numReady === false ) {
72 wfDebugLog( 'squid', __METHOD__ . ': Error in stream_select: ' .
74 break;
75 }
76
77 // Check for timeout, use 1% tolerance since we aimed at having socket_select()
78 // exit at precisely the overall timeout
79 if ( microtime( true ) - $startTime > $this->timeout * 0.99 ) {
80 wfDebugLog( 'squid', __CLASS__ . ": timeout ({$this->timeout}s)\n" );
81 break;
82 } elseif ( !$numReady ) {
83 continue;
84 }
85
86 foreach ( $readSockets as $key => $socket ) {
87 list( $clientIndex, ) = explode( '/', $key );
88 $client = $this->clients[$clientIndex];
89 $client->doReads();
90 }
91 foreach ( $writeSockets as $key => $socket ) {
92 list( $clientIndex, ) = explode( '/', $key );
93 $client = $this->clients[$clientIndex];
94 $client->doWrites();
95 }
96
97 $done = true;
98 foreach ( $this->clients as $client ) {
99 if ( !$client->isIdle() ) {
100 $done = false;
101 }
102 }
103 }
104
105 foreach ( $this->clients as $client ) {
106 $client->close();
107 }
108 }
109}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
SquidPurgeClient[] $clients
An HTTP 1.0 client built for the purposes of purging Squid and Varnish.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1999