Better mallinfo() output in --stats
authorMartin Pool <mbp@samba.org>
Fri, 11 Jan 2002 07:26:39 +0000 (07:26 +0000)
committerMartin Pool <mbp@samba.org>
Fri, 11 Jan 2002 07:26:39 +0000 (07:26 +0000)
main.c

diff --git a/main.c b/main.c
index 893883733db10bb744731d7be1a2083fb6a08fac..37ab2fbe29e1a4f72adef133c4a6869689715548 100644 (file)
--- a/main.c
+++ b/main.c
@@ -57,6 +57,11 @@ static void report(int f)
        extern int remote_version;
        int send_stats;
 
+       if (do_stats) {
+               /* These come out from every process */
+               show_malloc_stats();
+       }
+
        if (am_daemon) {
                log_exit(0, __FILE__, __LINE__);
                if (f == -1 || !am_sender) return;
@@ -120,7 +125,6 @@ static void report(int f)
                rprintf(FINFO,"total size is %.0f  speedup is %.2f\n",
                       (double)stats.total_size,
                       (1.0*stats.total_size)/(stats.total_written+stats.total_read));
-               show_malloc_stats();
        }
 
        fflush(stdout);
@@ -135,10 +139,17 @@ static void show_malloc_stats(void)
 {
 #ifdef HAVE_MALLINFO
        struct mallinfo mi;
+       extern int am_server;
+       extern int am_sender;
+       extern int am_daemon;
 
        mi = mallinfo();
 
-       rprintf(FINFO, RSYNC_NAME " heap statistics:\n");
+       rprintf(FINFO, RSYNC_NAME "[%d] (%s%s%s) heap statistics:\n",
+               getpid(),
+               am_server ? "server " : "",
+               am_daemon ? "daemon " : "",
+               am_sender ? "sender" : "receiver");
        rprintf(FINFO, "  arena:     %10d   (bytes from sbrk)\n", mi.arena);
        rprintf(FINFO, "  ordblks:   %10d   (chunks not in use)\n", mi.ordblks);
        rprintf(FINFO, "  smblks:    %10d\n", mi.smblks);