MediaWiki  REL1_19
SquidPurgeClient Class Reference

An HTTP 1.0 client built for the purposes of purging Squid and Varnish. More...

List of all members.

Public Member Functions

 __construct ($server, $options=array())
 close ()
 Close the socket but allow it to be reopened for future purge requests.
 doReads ()
 Read some data.
 doWrites ()
 Perform pending writes.
 getReadSocketsForSelect ()
 Get read socket array for select()
 getWriteSocketsForSelect ()
 Get write socket array for select()
 isIdle ()
 queuePurge ($url)
 Queue a purge operation.

Public Attributes

 $currentRequestIndex
 $host
 $ip
 $port
 $readState = 'idle'
 $requests = array()
 $socket
 The socket resource, or null for unconnected, or false for disabled due to error.
 $writeBuffer = ''
const BUFFER_SIZE = 8192
const EAGAIN = 11
const EINPROGRESS = 115
const EINTR = 4

Protected Member Functions

 getIP ()
 Get the host's IP address.
 getSocket ()
 Open a socket if there isn't one open already, return it.
 log ($msg)
 markDown ()
 Close the socket and ignore any future purge requests.
 nextRequest ()
 processHeaderLine ($line)
 processReadBuffer ()
 processStatusLine ($line)

Detailed Description

An HTTP 1.0 client built for the purposes of purging Squid and Varnish.

Uses asynchronous I/O, allowing purges to be done in a highly parallel manner.

Could be replaced by curl_multi_exec() or some such.

Definition at line 9 of file SquidPurgeClient.php.


Constructor & Destructor Documentation

SquidPurgeClient::__construct ( server,
options = array() 
)

Definition at line 27 of file SquidPurgeClient.php.


Member Function Documentation

Close the socket but allow it to be reopened for future purge requests.

Definition at line 131 of file SquidPurgeClient.php.

References wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by doReads(), and markDown().

Here is the call graph for this function:

Here is the caller graph for this function:

Read some data.

Call this when socket_select() indicates that the read buffer is non-empty.

Definition at line 205 of file SquidPurgeClient.php.

References $socket, close(), getSocket(), log(), markDown(), processReadBuffer(), wfRestoreWarnings(), and wfSuppressWarnings().

Here is the call graph for this function:

Perform pending writes.

Call this when socket_select() indicates that writing will not block.

Definition at line 170 of file SquidPurgeClient.php.

References $socket, getSocket(), log(), markDown(), wfRestoreWarnings(), and wfSuppressWarnings().

Here is the call graph for this function:

SquidPurgeClient::getIP ( ) [protected]

Get the host's IP address.

Does not support IPv6 at present due to the lack of a convenient interface in PHP.

Definition at line 101 of file SquidPurgeClient.php.

References IP\isIPv4(), IP\isIPv6(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by getSocket().

Here is the call graph for this function:

Here is the caller graph for this function:

Get read socket array for select()

Returns:
array

Definition at line 71 of file SquidPurgeClient.php.

References $socket, and getSocket().

Here is the call graph for this function:

SquidPurgeClient::getSocket ( ) [protected]

Open a socket if there isn't one open already, return it.

Returns false on error.

Returns:
false|resource

Definition at line 39 of file SquidPurgeClient.php.

References $ip, $ok, getIP(), log(), markDown(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().

Here is the call graph for this function:

Here is the caller graph for this function:

Get write socket array for select()

Returns:
array

Definition at line 86 of file SquidPurgeClient.php.

References $socket, and getSocket().

Here is the call graph for this function:

Returns:
bool

Definition at line 163 of file SquidPurgeClient.php.

SquidPurgeClient::log ( msg) [protected]

Definition at line 322 of file SquidPurgeClient.php.

References wfDebugLog().

Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().

Here is the call graph for this function:

Here is the caller graph for this function:

SquidPurgeClient::markDown ( ) [protected]

Close the socket and ignore any future purge requests.

This is called if there is a protocol error.

Definition at line 123 of file SquidPurgeClient.php.

References close().

Referenced by doReads(), doWrites(), getSocket(), and processStatusLine().

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 306 of file SquidPurgeClient.php.

Referenced by processReadBuffer(), and queuePurge().

Here is the caller graph for this function:

SquidPurgeClient::processHeaderLine ( line) [protected]
Parameters:
$linestring

Definition at line 298 of file SquidPurgeClient.php.

Referenced by processReadBuffer().

Here is the caller graph for this function:

Exceptions:
MWException
Returns:
string

Definition at line 236 of file SquidPurgeClient.php.

References $lines, nextRequest(), processHeaderLine(), and processStatusLine().

Referenced by doReads().

Here is the call graph for this function:

Here is the caller graph for this function:

SquidPurgeClient::processStatusLine ( line) [protected]
Parameters:
$line
Returns:

Definition at line 279 of file SquidPurgeClient.php.

References log(), and markDown().

Referenced by processReadBuffer().

Here is the call graph for this function:

Here is the caller graph for this function:

Queue a purge operation.

Parameters:
$urlstring

Definition at line 149 of file SquidPurgeClient.php.

References $url, expand, nextRequest(), and Http\userAgent().

Here is the call graph for this function:


Member Data Documentation

SquidPurgeClient::$currentRequestIndex

Definition at line 15 of file SquidPurgeClient.php.

SquidPurgeClient::$host

Definition at line 10 of file SquidPurgeClient.php.

SquidPurgeClient::$ip

Definition at line 10 of file SquidPurgeClient.php.

Referenced by getSocket().

SquidPurgeClient::$port

Definition at line 10 of file SquidPurgeClient.php.

SquidPurgeClient::$readState = 'idle'

Definition at line 12 of file SquidPurgeClient.php.

SquidPurgeClient::$requests = array()

Definition at line 14 of file SquidPurgeClient.php.

SquidPurgeClient::$socket

The socket resource, or null for unconnected, or false for disabled due to error.

Definition at line 25 of file SquidPurgeClient.php.

Referenced by doReads(), doWrites(), getReadSocketsForSelect(), and getWriteSocketsForSelect().

SquidPurgeClient::$writeBuffer = ''

Definition at line 13 of file SquidPurgeClient.php.

Definition at line 20 of file SquidPurgeClient.php.

Definition at line 18 of file SquidPurgeClient.php.

Definition at line 19 of file SquidPurgeClient.php.

Definition at line 17 of file SquidPurgeClient.php.


The documentation for this class was generated from the following file: