From: wessels <> Date: Tue, 14 Oct 1997 03:47:22 +0000 (+0000) Subject: adding new X-Git-Tag: SQUID_3_0_PRE1~4803 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f36d1b4431f584300983d04d0629c74e3c628e1f;p=thirdparty%2Fsquid.git adding new --- diff --git a/doc/Programming-Guide/Makefile b/doc/Programming-Guide/Makefile new file mode 100644 index 0000000000..ea4346c4dc --- /dev/null +++ b/doc/Programming-Guide/Makefile @@ -0,0 +1,24 @@ +DOC = prog-guide + +all: $(DOC).html $(DOC).ps + +$(DOC).ps: $(DOC).dvi + dvips $(DOC).dvi + +$(DOC).dvi: $(DOC).sgml + sgml2latex $(DOC) + +#$(DOC).dvi: $(DOC).tex +# latex $(DOC).tex +# latex $(DOC).tex +# latex $(DOC).tex +# +#$(DOC).tex: $(DOC).sgml +# sgml2latex $(DOC) + +$(DOC).html: $(DOC).sgml + sgml2html $(DOC) + +clean: + rm -f *.html + rm -f $(DOC).tex $(DOC).ps $(DOC).dvi $(DOC).aux $(DOC).log $(DOC).toc diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml new file mode 100644 index 0000000000..0968edd048 --- /dev/null +++ b/doc/Programming-Guide/prog-guide.sgml @@ -0,0 +1,325 @@ + +
+Squid Programmers Guide +Duane Wessels, Squid Developers + + +Squid is a WWW Cache application developed by the National Laboratory +for Applied Network Research and members of the Web Caching community. +Squid is implemented as a single, non-blocking process based around +a BSD select() loop. This document describes the operation of the Squid +source code and is intended to be used by others who wish to customize +or improve it. + + + + +Introduction + +

+The Squid source code has evolved more from empirical observation and +tinkering, rather than a solid design process. It carries a legacy of +being ``touched'' by numerous individuals, each with somewhat different +techniques and terminology. + +

+Squid is a single-process proxy server. Every request is handled by +the main process, with the exception of FTP. However, Squid does not +use a ``threads package'' such has Pthreads. While this might be +easier to code, it suffers from portability and performance problems. +Instead Squid maintains data structures and state information for +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. + +

+Note there is only a pseudo-consistent naming scheme. In most +cases functions are named like +Note that the Squid source changes rapidly, and some parts of this +document may become out-of-date. If you find any inconsistencies, please +feel free to notify +. + +Conventions + +

+Function names and file names will be written in a courier font, such +as The Big Picture + +

+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 + Storage Manager + +

+ 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 + +

+ +IP/FQDN Cache + + A cache of name-to-address and address-to-name lookups. These are + hash tables keyed on the names and addresses. + + +Function Sequence of a Typical Request + +

+ + asciiHandleConn + clientReadRequest + parseHttpRequest + clientAccessCheck -- clientAccessCheckDone + redirectStart -- clientRedirectDone + icpProcessRequest + icpProcessMISS + protoDispatch -- protoDispatchDNSHandle + protoStart + proxyhttpStart + httpConnect -- httpConnectDone + httpSendRequest -- httpSendComplete + + while (data arriving from server) { + httpReadReply + storeAppend + InvokeHandlers + icpHandleStore + icpSendMoreData + } + + storeComplete + comm_close(server socket) + httpStateFree + comm_close(client_socket) + icpStateFree + + + + +The Main Loop: +At the core of Squid is the Comm Handlers + +

+For every open file descriptor, there are N types of handler functions. + +Read +Write +Timeout +Lifetime +Close + + +

+These handlers are stored in the + typedef void (*PF) (int, void *); + +The close handler is really a linked list of handler functions. +Each handler also has an associated pointer + +After each handler is called, +Typical read handlers are + +The close handlers are normally called from +The timeout and lifetime handlers are called for file descriptors which +have been idle for too long. They are futher discussed in a following +chapter. + + +Data Structures +Main Config + + +Storage Manager + + +IP Cache + + +Server Protocols +HTTP +FTP +Gopher +Wais +SSL +Passthrough + + +Timeouts + + +Events + + +Access Controls + + +ICP + + +Cache Manager + +