memory: Avoid 100% CPU when there is nothing to report.
authorBen Pfaff <blp@nicira.com>
Thu, 11 Apr 2013 22:05:32 +0000 (15:05 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 11 Apr 2013 22:52:58 +0000 (15:52 -0700)
Commit b9de4087685 (memory: Avoid an empty log message if there's nothing
to log.) introduced a 100% CPU usage condition when there is nothing to
log.  This fixes the problem.

Reported-by: Ansis Atteka <aatteka@nicira.com>
Acked-by: Ansis Atteka <aatteka@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/memory.c

index c26c743..1137390 100644 (file)
@@ -137,8 +137,10 @@ memory_report(const struct simap *usage)
     ds_init(&s);
     compose_report(usage, &s);
 
     ds_init(&s);
     compose_report(usage, &s);
 
-    if (want_report && s.length) {
-        VLOG_INFO("%s", ds_cstr(&s));
+    if (want_report) {
+        if (s.length) {
+            VLOG_INFO("%s", ds_cstr(&s));
+        }
         want_report = false;
     }
     if (n_conns) {
         want_report = false;
     }
     if (n_conns) {