Memory leak in tradspool code
Russ Allbery
rra at stanford.edu
Mon Nov 4 23:45:05 UTC 2002
I've been fighting some memory issues on my new news server based on INN
CURRENT, particularly with expire (*not* expireover). After poking around
a little bit, I think I found the cause. As near as I can tell, the
actual ARTHANDLE struct allocated by tradspool_retrieve is never being
freed, nor is the PRIV_TRADSPOOL structure where it's allocated.
Since expire nightly does a RETR_STAT of every article in the spool, this
is resulting in a huge memory leak, which explains why expire was growing
to be considerably larger than innd.
I think this fix is correct, and I don't think that the article handle is
being stashed anywhere in the code, but just as a double-check, I figured
I'd post the patch and see if anyone else can see something wrong with it.
Index: tradspool.c
===================================================================
RCS file: /dist1/cvs/isc/inn/inn/storage/tradspool/tradspool.c,v
retrieving revision 1.41
diff -u -p -r1.41 tradspool.c
--- tradspool.c 2002/09/04 03:47:29 1.41
+++ tradspool.c 2002/11/04 23:44:16
@@ -899,22 +899,25 @@ tradspool_retrieve(const TOKEN token, co
}
void
-tradspool_freearticle(ARTHANDLE *article) {
+tradspool_freearticle(ARTHANDLE *article)
+{
PRIV_TRADSPOOL *private;
- if (!article) return;
+ if (article == NULL)
+ return;
if (article->private) {
private = (PRIV_TRADSPOOL *) article->private;
if (private->mmapped)
munmap(private->artbase, private->artlen);
else
- DISPOSE(private->artbase);
- if (private->curdir) {
+ free(private->artbase);
+ if (private->curdir)
closedir(private->curdir);
- }
- DISPOSE(private->curdirname);
+ free(private->curdirname);
+ free(private);
}
+ free(article);
}
bool
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
Please send questions to the list rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
More information about the inn-workers
mailing list