https://bugzilla.wikimedia.org/show_bug.cgi?id=27658

           Summary: SquidPurgeClient fails on FreeBSD; incorrect constants
                    + MSG_EOR w/ SOCK_STREAM
           Product: MediaWiki
           Version: unspecified
          Platform: All
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: General/Unknown
        AssignedTo: wikibugs-l@lists.wikimedia.org
        ReportedBy: greenrea...@hotmail.com


On FreeBSD, the new SquidPurgeClient fails to write to the socket it opens (and
thus fails to purge from the cache) for a couple of reasons:

* On FreeBSD, EAGAIN is 35, and EINPROGRESS is 36, which do not match the
(linux?) constants defined in SquidPurgeClient.php, thus causing getSocket() to
return false when it actually created the socket correctly:
http://fxr.watson.org/fxr/source/sys/errno.h?v=DFBSD

* On FreeBSD, setting MSG_EOR on a SOCK_STREAM socket (as done in doWrites())
will result in EINVAL, so even if it gets the sockets, writing to them fails:
http://fxr.watson.org/fxr/source/kern/uipc_socket.c?v=OPENBSD;im=bigexcerpts#L378
I believe you are only meant to use MSG_EOR with SOCK_SEQPACKET.

Adjusting the constants to match those of FreeBSD and changing the $flags
parameter to 0 in doWrites fixed this problem for me on FreeBSD 8.1-RELEASE-p1.
Perhaps there's a better way to detect these platform-specific constants?

---

For what it's worth, I also added in a few more writes for Varnish, because it
won't purge gzip and deflate versions unless you ask. Not sure if it's required
for Squid (and there might be a better way to do this in VCL, too), but it was
much easier with the new architecture:

public function queuePurge( $url ) {
  $urlparts = parse_url(str_replace( "\n", '', $url ));
  $msg =  'PURGE ' . $urlparts['path'] . " HTTP/1.0\r\n" .
          'Host: ' . $urlparts['host'] . "\r\n".
          "Connection: Keep-Alive\r\n" .
          "Proxy-Connection: Keep-Alive\r\n" .
          'User-Agent: ' . Http::userAgent() . ' ' . __CLASS__ . "\r\n";
  $this->requests[] = $msg . "\r\n";
  $this->requests[] = $msg . "Accept-Encoding: gzip\r\n\r\n";
  $this->requests[] = $msg . "Accept-Encoding: deflate\r\n\r\n";
...

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to