Previous Next Table of Contents

3. Compiling

3.1 src/Makefile options

The Squid Makefile includes numerous options that you may define before compiling. These enable certain customizations and/or non-standard features described below. As of this writing, the options below were present in the Squid 1.1.15 src/Makefile. If you want to define these before running configure then you would edit src/Makefile.in.

HOST_OPT

Normally the cachemgr.cgi program brings up the main HTML form with the hostname field blank. Some administrators grow weary from continually entering hostnames, so this option allows a default hostname to be set for that field.

AUTH_OPT

Jon Thackray has written some optionally-compiled code to support proxy authentication. In addition to enabling this option in the Makefile, you must also define a password file with the proxy_auth option in squid.conf.

LOG_HDRS_OPT

Ron Gomes has written some optionally-compiled code to log FULL request and response headers to access.log. The headers are encoded safely and will appear as two bracketed fields at the end of each line. The log_mime_hdrs option must also be enabled in squid.conf.

ICMP_OPT

This option enables using ICMP (ala ping) to measure the proximity of origin servers. This feature is fully described in using-icmp.

DELAY_HACK

Mike Groeneweg has written some optionally-compiled code to delay the requests of certain users. Requests matching the delay_access ACL rules (similar to http_access) will be artificially delayed by the neighbor_timeout amount.

USERAGENT_OPT

Joe Ramey has written some optionally-compiled code to log the value of the User-Agent request header to a separate useragent.log file.

KILL_PARENT_OPT

When this option is defined, Squid sends a kill signal to its parent process (assuming it to be the RunCache script) when Squid terminates. This feature is a bit dangerous, so use at your own risk.

USE_POLL_OPT

Some operating systems may perform better when the poll() function call is available. poll() would be used in place of select(). Solaris', select() only supports 1024 file descriptors (even if the process limit is higher). poll() should be used if you need more than 1024 descriptors on Solaris.

USE_SPLAY_TREE

By default, Squid stores IP access list entries as a linked-list. Linear searches on these lists may be inefficient. This optionally-compiled code stores IP access lists as SPLAY trees. No analysis has been done to prove that this implementation is significantly more efficient, however.

USE_BIN_TREE

Another option to linear linked-lists of IP access controls. With this option, binary balanced trees are used to store the access lists.

RELOAD_INTO_IMS

Some administrators have asked for the ability to change a no-cache request into an If-Modified-Since request. When this option is defined, Squid will strip the no-cache request header and insert an If-Modified-Since header with last-valid time of the cached object. If the request already includes an If-Modified-Since header, it will be unchanged. Use of this feature means that cache users will have no way to enforce a refresh if a bad or outdated page gets cached and the dates get out of sync, or if a partial object somehow becomes cached.

3.2 undefined reference to __inet_ntoa

by Kevin Sartorelli and Andreas Doering.

Probably you've recently installed bind 8.x. There is a mismatch between the header files and DNS library that Squid has found. There are a couple of things you can try.

First, try adding -lbind to XTRA_LIBS in src/Makefile. If -lresolv is already there, remove it.

If that doesn't seem to work, edit your arpa/inet.h file and comment out the following:

#define inet_addr __inet_addr #define inet_aton __inet_aton #define inet_lnaof __inet_lnaof #define inet_makeaddr __inet_makeaddr #define inet_neta __inet_neta #define inet_netof __inet_netof #define inet_network __inet_network #define inet_net_ntop __inet_net_ntop #define inet_net_pton __inet_net_pton #define inet_ntoa __inet_ntoa #define inet_pton __inet_pton #define inet_ntop __inet_ntop #define inet_nsap_addr __inet_nsap_addr #define inet_nsap_ntoa __inet_nsap_ntoa

3.3 Using GNU malloc

Many users have found improved performance when linking Squid with an external malloc library, such as GNU malloc. To make Squid use GNU malloc follow these simple steps:

  1. Download the GNU malloc source, available from one of The GNU FTP Mirror sites.
  2. Compile GNU malloc % gzip -dc malloc.tar.gz | tar xf - % cd malloc % vi Makefile # edit as needed % make
  3. Copy libmalloc.a to your system's library directory and be sure to name it libgnumalloc.a. % su # cp malloc.a /usr/lib/libgnumalloc.a
  4. (Optional) Copy the GNU malloc.h to your system's include directory and be sure to name it gnumalloc.h. This step is not required, but if you do this, then Squid will be able to use the mstat() function to report memory usage statistics on the cachemgr info page. # cp malloc.h /usr/lib/gnumalloc.h
  5. Reconfigure and recompile Squid % make realclean % ./configure ... % make % make install Note, In later distributions, 'realclean' has been changed to 'distclean'. As the configure script runs, watch its output. You should find that it locates libgnumalloc.a and optionally gnumalloc.h.

3.4 How can I get true DNS TTL info into Squid's IP cache?

If you have source for BIND, you can modify it as indicated in the diff below. It causes the global variable _dns_ttl_ to be set with the TTL of the most recent lookup. Then, when you compile Squid, the configure script will look for the _dns_ttl_ symbol in libresolv.a. If found, dnsserver will return the TTL value for every lookup.

This hack was contributed by Endre Balint Nagy.

diff -ru bind-4.9.4-orig/res/gethnamaddr.c bind-4.9.4/res/gethnamaddr.c --- bind-4.9.4-orig/res/gethnamaddr.c Mon Aug 5 02:31:35 1996 +++ bind-4.9.4/res/gethnamaddr.c Tue Aug 27 15:33:11 1996 @@ -133,6 +133,7 @@ } align; extern int h_errno; +int _dns_ttl_; #ifdef DEBUG static void @@ -223,6 +224,7 @@ host.h_addr_list = h_addr_ptrs; haveanswer = 0; had_error = 0; + _dns_ttl_ = -1; while (ancount-- > 0 && cp < eom && !had_error) { n = dn_expand(answer->buf, eom, cp, bp, buflen); if ((n < 0) || !(*name_ok)(bp)) { @@ -232,8 +234,11 @@ cp += n; /* name */ type = _getshort(cp); cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ + INT32SZ; /* class, TTL */ + class = _getshort(cp); + cp += INT16SZ; /* class */ + if (qtype == T_A && type == T_A) + _dns_ttl_ = _getlong(cp); + cp += INT32SZ; /* TTL */ n = _getshort(cp); cp += INT16SZ; /* len */ if (class != C_IN) {

3.5 My platform is BSD/OS or BSDI and I can't compile Squid

cache_cf.c: In function `parseConfigFile': cache_cf.c:1353: yacc stack overflow before `token' ...

You need to upgrade your gcc installation to a more recent version, say 2.7.2.


Previous Next Table of Contents