Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/libexec/lfs_cleanerd Pull up revision 1.18 (requested b...



details:   https://anonhg.NetBSD.org/src/rev/5c94cc4a25a3
branches:  netbsd-1-4
changeset: 470210:5c94cc4a25a3
user:      he <he%NetBSD.org@localhost>
date:      Mon Jan 31 19:05:48 2000 +0000

description:
Pull up revision 1.18 (requested by perseant):
  Fix a few memory leaks in lfs_cleanerd.

diffstat:

 libexec/lfs_cleanerd/cleanerd.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (58 lines):

diff -r 8da7e69b9cba -r 5c94cc4a25a3 libexec/lfs_cleanerd/cleanerd.c
--- a/libexec/lfs_cleanerd/cleanerd.c   Mon Jan 31 19:03:11 2000 +0000
+++ b/libexec/lfs_cleanerd/cleanerd.c   Mon Jan 31 19:05:48 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cleanerd.c,v 1.13.2.3 1999/12/16 23:50:11 he Exp $     */
+/*     $NetBSD: cleanerd.c,v 1.13.2.4 2000/01/31 19:05:48 he Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)cleanerd.c 8.5 (Berkeley) 6/10/95";
 #else
-__RCSID("$NetBSD: cleanerd.c,v 1.13.2.3 1999/12/16 23:50:11 he Exp $");
+__RCSID("$NetBSD: cleanerd.c,v 1.13.2.4 2000/01/31 19:05:48 he Exp $");
 #endif
 #endif /* not lint */
 
@@ -421,6 +421,8 @@
        struct seglist *segs, *sp;
        long int to_clean, cleaned_bytes;
        unsigned long i, j, total;
+       struct rusage ru;
+       int error;
 
        if ((segs =
            malloc(fsp->fi_lfs.lfs_nseg * sizeof(struct seglist))) == NULL) {
@@ -440,8 +442,10 @@
                sp++;
                i--;
        }
-       if(j > nsegs)
+       if(j > nsegs) {
+               free(segs);
                return;
+       }
 
        /* If we relly need to clean a lot, do it now */
        if(fsp->fi_cip->clean < 2*MIN_FREE_SEGS)
@@ -496,11 +500,13 @@
        }
        free(segs);
        if(debug) {
-               struct rusage ru;
-
-               getrusage(RUSAGE_SELF,&ru);
-               syslog(LOG_DEBUG,"Current usage: maxrss=%ld, idrss=%ld",
-                      ru.ru_maxrss,ru.ru_idrss);
+               error=getrusage(RUSAGE_SELF,&ru);
+               if(error) {
+                       syslog(LOG_INFO,"getrusage returned error: %m");
+               } else {
+                       syslog(LOG_DEBUG,"Current usage: maxrss=%ld, idrss=%ld, isrss=%ld",
+                              ru.ru_maxrss,ru.ru_idrss,ru.ru_isrss);
+               }
        }
 }
 



Home | Main Index | Thread Index | Old Index