From 56cae6e16d22dfba1aafe91dc3465a684d808124 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 5 Nov 2008 21:59:55 +0000 Subject: [PATCH] Don't forget to munmap everything we've mmapped in all modes. Otherwise chaining modes is liable to run out of address space rather rapidly. git-svn-id: svn://svn.tartarus.org/sgt/agedu@8284 cda61777-01e9-0310-a592-d414129be87e --- GNUmakefile | 2 +- TODO | 3 --- agedu.c | 7 +++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index cd7229e..9f5eaf7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -28,7 +28,7 @@ agedu: config.h $(AGEDU_OBJS) gcc $(LFLAGS) -o agedu $(AGEDU_OBJS) config.h: configure - ./configure + ./configure -q rm -f Makefile # we keep using _this_ Makefile configure: configure.ac diff --git a/TODO b/TODO index 6549737..d97494c 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,6 @@ TODO list for agedu =================== - - we should munmap in all operating modes where we mmapped, - otherwise chaining them will run out of address space - - we could still be using more of the information coming from autoconf. Our config.h is defining a whole bunch of HAVE_FOOs for particular functions (e.g. HAVE_INET_NTOA, HAVE_MEMCHR, diff --git a/agedu.c b/agedu.c index 5bd05d4..533dc4c 100644 --- a/agedu.c +++ b/agedu.c @@ -1097,6 +1097,8 @@ int main(int argc, char **argv) querydir[--pathlen] = '\0'; text_query(mappedfile, querydir, textcutoff, tqdepth); + + munmap(mappedfile, totalsize); } else if (mode == HTML) { char *querydir = actions[action].arg; size_t pathlen; @@ -1136,6 +1138,8 @@ int main(int argc, char **argv) cfg.newest = htmlnewest; html = html_query(mappedfile, xi, &cfg); fputs(html, stdout); + + munmap(mappedfile, totalsize); } else if (mode == DUMP) { size_t maxpathlen; char *buf; @@ -1166,6 +1170,8 @@ int main(int argc, char **argv) while ((tf = triewalk_next(tw, buf)) != NULL) dump_line(buf, tf); triewalk_free(tw); + + munmap(mappedfile, totalsize); } else if (mode == HTTPD) { struct html_config pcfg; struct httpd_config dcfg; @@ -1196,6 +1202,7 @@ int main(int argc, char **argv) pcfg.oldest = htmloldest; pcfg.newest = htmlnewest; run_httpd(mappedfile, auth, &dcfg, &pcfg); + munmap(mappedfile, totalsize); } else if (mode == REMOVE) { if (remove(filename) < 0) { fprintf(stderr, "%s: %s: remove: %s\n", PNAME, filename, -- 2.11.0