MediaWiki  1.32.5
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  while ( !$done ) {
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;
58  }
59  $sockets = $client->getWriteSocketsForSelect();
60  foreach ( $sockets as $i => $socket ) {
61  $writeSockets["$clientIndex/$i"] = $socket;
62  }
63  }
64  if ( !count( $readSockets ) && !count( $writeSockets ) ) {
65  break;
66  }
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" );
75  break;
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  foreach ( $this->clients as $client ) {
105  $client->close();
106  }
107  }
108 }
SquidPurgeClientPool\__construct
__construct( $options=[])
Definition: SquidPurgeClientPool.php:32
captcha-old.count
count
Definition: captcha-old.py:249
SquidPurgeClientPool\$clients
array $clients
Array of SquidPurgeClient.
Definition: SquidPurgeClientPool.php:24
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1082
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
SquidPurgeClientPool
Definition: SquidPurgeClientPool.php:22
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
list
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
$options
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:2044
SquidPurgeClientPool\run
run()
Definition: SquidPurgeClientPool.php:46
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
SquidPurgeClientPool\$timeout
int $timeout
Definition: SquidPurgeClientPool.php:27
SquidPurgeClientPool\addClient
addClient( $client)
Definition: SquidPurgeClientPool.php:42