From: wessels <> Date: Tue, 10 Feb 1998 12:38:26 +0000 (+0000) Subject: update X-Git-Tag: SQUID_3_0_PRE1~4126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53b0dbb4a70a3ccb107ddf25985e9715f160bf92;p=thirdparty%2Fsquid.git update --- diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index 1aef7cb09b..e2c7c6d73a 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -1,7 +1,7 @@
-Squid Programmers Guide -Duane Wessels, Squid Developers +Squid v1.2 Programmers Guide +Duane Wessels, Kostas Anagnostakis, Alex Rousskov, Squid Developers Squid is a WWW Cache application developed by the National Laboratory @@ -33,9 +33,10 @@ each active request.

The code is often difficult to follow because there are no explicit state variables for the active requests. Instead, thread execution -progresses as a sequence of ``handler functions'' which get called -when I/O is ready to occur. As a handler completes, it will register -another handler for the next time I/O occurs. +progresses as a sequence of ``callback functions'' which get executed +when I/O is ready to occur, or some other event has happened. As +a callback function completes, it is responsible for registering the +next callback function for subsequent I/O.

Note there is only a pseudo-consistent naming scheme. In most @@ -53,7 +54,7 @@ name="the Squid Developers">.

Function names and file names will be written in a courier font, such -as The Big Picture @@ -64,44 +65,37 @@ Squid consists of the following major components Client Side

- These routines exist primarily in two source files: - This is where new client connections are accepted and processed. - This is where we determine if the request is a HIT, REFRESH, MISS, etc. - The client-side state for each request is held in an Server Side

- These routines exist in various source files. - This is where server connections are made, and replies are read. - Apart from processing headers, HTTP is relatively simple--just - copying bytes. Note that all requests (FTP, Gopher) to other - proxies are sent as HTTP requests. Requests to FTP servers are - handled in the external - The Storage Manager is the glue between client and server sides. Every object saved in the cache is allocated a - The - Squid can quickly located cached objects because it keeps a hash - table of all Objects are saved to disk in a two-level directory structure. For each object the - When new object data arrives on the server side, it is added to the - Other Components +

+ The storage manager code resides in a number of files: + Peer Selection

- -Access Control + +

+ The functions in Network Communication + +

+ The file File/Disk I/O + +

+ Routines for reading and writing disk files (and FIFOs) are + implemented in Other Components +Neighbors + +

Maintains the list of neighbor caches. Sends and receives - ICP messages to neighbors. File: IP/FQDN Cache +IP/FQDN Cache +

A cache of name-to-address and address-to-name lookups. These are hash tables keyed on the names and addresses. Cache Manager + +

+ This provides access to certain information needed by the + cache administrator. A companion program, + cache_object://hostname/operation + + The cache manager provides essentially ``read-only'' access + to information. It does not provide a method for configuring + Squid while it is running. + +Network Measurement Database - + In a number of situation, Squid finds it useful to know the + estimated network round-trip time (RTT) between itself and + origin servers. A particularly useful is example is + the peer selection algorithm. By making RTT measurements, a + Squid cache will know if it, or one if its neighbors, is closest + to a given origin server. The actual measurements are made + with the Redirectors + +

+ Squid has the ability to rewrite requests from clients. After + checking the access controls, but before checking for cache hits, + requested URLs may optionally be written to an external + Autonomous System Numbers + +

+ Squid supports Autonomous System (AS) numbers as another + access control element. The routines in Asynchronous I/O Operations + +

+ These routines in Configuation File Parsing + +

+ The primary configuration file specification is in the file + Callback Data Database + +

+ Squid's extensive use of callback functions makes it very + susceptible to memory access errors. Care must be taken + so that the Debugging + +

+ Squid includes extensive debugging statements to assist in + tracking down bugs and strange behaviour. Every debug statement + is assigned a section and level. Usually, every debug statement + in the same source file has the same section. Levels are chosen + depending on how much output will be generated, or how useful the + provided information will be. The Error Generation + +

+ The routines in Event Queue + +

+ The routines in Filedescriptor Managment +Hashtable Support +HTTP Anonymization +Internet Cache Protocol +Ident Lookups +Memory Management +Multicast Support +Persistent Server Connections +Refresh Rules +Request Redirection +SNMP Support +URN Support + +External Programs + +dnsserver + +

Because the standard +pinger +unlinkd +redirector Function Sequence of a Typical Request @@ -238,7 +410,7 @@ For every open file descriptor, there are N types of handler functions.

These handlers are stored in the @@ -392,6 +564,67 @@ according to the Error Pages +Callback Data Database + +

+ Squid's extensive use of callback functions makes it very + susceptible to memory access errors. For a blocking operation + with callback functions, the normal sequence of events is as + follows: + + callback_data = malloc(...); + ... + fooOperationStart(bar, callback_func, callback_data); + ... + fooOperationComplete(...); + callback_func(callback_data, ....); + ... + free(callback_data); + + However, things become more interesting if we want or need + to free the callback_data, or otherwise cancel the callback, + before the operation completes. + +

+ The callback data database lets us do this in a uniform and + safe manner. Every callback_data pointer must be added to the + database. It is then locked while the blocking operation executes + elsewhere, and is freed when the operation completes. The normal + sequence of events is: + + callback_data = malloc(...); + cbdataAdd(callback_data); + ... + cbdataLock(callback_data); + fooOperationStart(bar, callback_func, callback_data); + ... + fooOperationComplete(...); + if (cbdataValid(callback_data) { + callback_func(callback_data, ....); + cbdataUnlock(callback_data); + cbdataFree(callback_data); + + +

+ With this scheme, nothing bad happens if + callback_data = malloc(...); + cbdataAdd(callback_data); + ... + cbdataLock(callback_data); + fooOperationStart(bar, callback_func, callback_data); + ... + cbdataFree(callback_data); + ... + fooOperationComplete(...); + if (cbdataValid(callback_data) { + callback_func(callback_data, ....); + cbdataUnlock(callback_data); + + In this case,