Re: pconn's don't use MemPools ?

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Thu, 21 Sep 2000 00:32:26 +0200

Andres Kroonmaa wrote:

> ok, I'd like to try once. I've found that ssl.c isn't using pools.
> it allocs:
> sslState = xcalloc(1, sizeof(SslStateData));
> sslState->server.buf = xmalloc(SQUID_TCP_SO_RCVBUF);
> sslState->client.buf = xmalloc(SQUID_TCP_SO_RCVBUF);
> What naming convention should be used? should I add new define
> called SSL_SERVER_BUF to use in memDataInit as size?

Good question. ssl.c is a bit messy to convert. It is a module in
itself, but not using any startup or shutdown functions.

SslStateData is locally defined in ssl.c, so you cannot make a memData
type of it. Here you have to use a direct memory pool.

At the toplevel, add a static variable for the pool:

static MemPool *ssl_state_pool = NULL;

Then replace the three lines with the following fragment:

    if (!ssl_state_pool)
        ssl_state_pool = memPoolCreate("SslStateData", sizeof(SslStateData));
    sslState = memPoolAlloc(ssl_state_pool);
    sslState->server.buf = memAllocate(MEM_CLIENT_SOCK_BUF);
    sslState->client.buf = memAllocate(MEM_CLIENT_SOCK_BUF);

Then you have to change the cbdataAdd call to use another free method
and all uses of the server.buf and client.buf to use the correct size,
and change sslFree to free them in a correct manner.

If you want to play fancy then you move the memPoolCreate to a
initialisation function for the ssl.c module, and also add a shutdown
function to have the MemoryPool destroyed on shutdown. (see main.c on
where to hook in these two functions).

> Well, found it. Seems to be heap-relpacement reallocing its mem usage
> several times.

Makes sense. The HEAP can get quite large. Perhaps there should be a
parameter to initialize the size of the HEAP?

/Henrik
Received on Wed Sep 20 2000 - 16:55:11 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:38 MST