squid debugging
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 30 Jun 2004 02:02:43 +0000 (02:02 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 30 Jun 2004 02:02:43 +0000 (02:02 +0000)
includes/DefaultSettings.php
includes/SquidUpdate.php

index ac993c7..e57244c 100644 (file)
@@ -245,6 +245,7 @@ $wgProfileToDatabase = false; # Log sums from profiling into "profiling" table i
 $wgProfileSampleRate = 1; # Only profile every n requests when profiling is turned on
 $wgDebugProfiling = false; # Detects non-matching wfProfileIn/wfProfileOut calls
 $wgDebugFunctionEntry = 0; # Output debug message on every wfProfileIn/wfProfileOut
+$wgDebugSquid = false; # Lots of debugging output from SquidUpdate.php
 
 $wgDisableCounters = false;
 $wgDisableTextSearch = false;
index 462de3f..bb90029 100644 (file)
@@ -85,14 +85,20 @@ class SquidUpdate {
                                        /* first socket for this server, do the tests */
                                        @list($server, $port) = explode(':', $wgSquidServers[$ss]);
                                        if(!isset($port)) $port = 80;
+                                       $this->debug("Opening socket to $server:$port");
                                        $socket = @fsockopen($server, $port, $error, $errstr, 3);
+                                       $this->debug("\n");
                                        if (!$socket) {
                                                $failed = true;
                                                $totalsockets -= $sockspersq;
                                        } else {
-                                               @fputs($socket,"PURGE " . $firsturl . " HTTP/1.0\r\n".
-                                               "Connection: Keep-Alive\r\n\r\n");
+                                               $msg ="PURGE " . $firsturl . " HTTP/1.0\r\n".
+                                               "Connection: Keep-Alive\r\n\r\n";
+                                               $this->debug($msg);
+                                               @fputs($socket,$msg);
+                                               $this->debug("...");
                                                $res = @fread($socket,512);
+                                               $this->debug("\n");
                                                /* Squid only returns http headers with 200 or 404 status, 
                                                if there's more returned something's wrong */
                                                if (strlen($res) > 250) {
@@ -129,12 +135,15 @@ class SquidUpdate {
                                                }
                                        }
                                        $urindex = $r + $urlspersocket * ($s - $sockspersq * floor($s / $sockspersq));
-                                       @fputs($sockets[$s],"PURGE " . $urlArr[$urindex] . " HTTP/1.0\r\n".
-                                       "Connection: Keep-Alive\r\n\r\n");
+                                       $msg = "PURGE " . $urlArr[$urindex] . " HTTP/1.0\r\n".
+                                       "Connection: Keep-Alive\r\n\r\n";
+                                       $this->debug($msg);
+                                       @fputs($sockets[$s],$msg);
+                                       $this->debug("\n");
                                }
                        }
                }
-
+               $this->debug("Reading response...");
                foreach ($sockets as $socket) {
                        $res = '';
                        $esc = 0;
@@ -146,6 +155,14 @@ class SquidUpdate {
 
                        @fclose($socket);
                }
+               $this->debug("\n");
+       }
+
+       function debug( $text ) {
+               global $wgDebugSquid;
+               if ( $wgDebugSquid ) {
+                       wfDebug( $text );
+               }
        }
 }
 ?>