next up previous
Next: Connection handling Up: Design for a Web Previous: Cache Management

Implementation

Since the code base was already established and code reuse was encouraged, my main implementation problem is creating the kind of cache mechanism that I want. A large part of the work went into getting to know the implementation details of the framework well enough so that I could alter and add to the code where I wanted to.

The proxy is implemented as a single threaded application, that uses non-blocking systems calls to handle many clients at once. The proxy starts by initializing all variables and the cache table. This includes reading the latest cache state from disk, which allows for a graceful cache reboot after a crash. After that the proxy creates the listening socket.

Finally the proxy enters a non-exiting loop, described in pseudo code:

begin loop
    create a client object for a connection request;
    begin loop over all client objects
       if the client wants to read/write then
           use a netpipe to handle it;
       update client state;
    end loop
    if idle then
       flush cache to disk;
end loop



 

Magnus Bjornsson
1998-05-08