Re: aiops.c and xmalloc

From: Adrian Chadd <adrian@dont-contact.us>
Date: Thu, 5 Oct 2000 06:27:01 +0800

On Wed, Oct 04, 2000, Henrik Nordstrom wrote:
> Andres Kroonmaa wrote:
> >
> > aiops.c has several xmallocs in form of:
> >
> > if ((requestp->path = (char *) xmalloc(len)) == NULL) {
> > memPoolFree(aio_request_pool, requestp);
> > errno = ENOMEM;
> > return -1;
> > }
> >
> > AFAIK xmalloc cannot ever return with NULL, so this check
> > seems useless.
>
> True, but Stewart was not sure about this when he wrote it once in a
> time.. might be that xmalloc was not even used then.
>
> > Is it there for some reason or is just remains since times
> > when xmalloc was not used?
>
> Purely old remains. Not needed today, but since it is there why removing
> it..
>
> > Is there any reason why aiops needs to copy path strings
> > into private membuffer instead of just miving pointer?
>
> Yes. The path memory area is reused on the next object open attempt,
> which might come way before the first one has even started..
>
> > I'm looking into possible memleaks in aiops and I wanted to
> > convert it into using memPools.
>
> I prefer attacking it from a architectural point, to build an
> architecture where asyncronous operations are supported without
> requiring the duplicating hacks done by aiops to isolate the callers
> from the asyncronous nature...

I believe this is the reasoning for the above code - the aiops code was
designed to be standalone. It appeared to me that way, and I believe
you also told me this once. :) This explains stuff like why there is
so much memory duplication/copying because the aiops can't assume the
memory is going to stick around until the write/read completion.

The modio 2 patchset deals with this. I'm also planning on making a bunch
of 'generic' functions (eg the store rebuild shared between ufs/aufs/diskd
gets stuck into a library rather than the same code being duplicated..)
which I'm actually thinking of committing to squid-HEAD before the branch
(its not a new feature, its just making things tidier, if anyone has a
problem with me doing it, let me know.)

> Of the 4 xmalloc calls there is in aiops, only one is easily
> transferrable to memory pools.. (the struct stat one).

If the above is what I think it is, assert the string length and use
a short string. Perhaps a PATH mempool should be created for this
kind of use?

Adrian

-- 
Adrian Chadd			"If a butterfly flaps its wings in China,
<adrian@creative.net.au>	    will a woman get naked in Amsterdam?"
				      -- Ashley Penney on Chaos Theory
Received on Wed Oct 04 2000 - 16:27:16 MDT

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