From: Ben Pfaff Date: Thu, 30 Apr 2009 21:45:30 +0000 (-0700) Subject: leak-checker: Stop logging after an output error. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a462aa5f9340b87853ff3f94cce3c84ebb059cc;p=openvswitch leak-checker: Stop logging after an output error. In particular it's not polite to continue trying to write to the output file after ENOSPC, since it will immediately fill up the disk again should anyone free up any space and keeping the log file open prevents usefully deleting it. --- diff --git a/lib/leak-checker.c b/lib/leak-checker.c index fbca299d..83576af2 100644 --- a/lib/leak-checker.c +++ b/lib/leak-checker.c @@ -168,19 +168,27 @@ reset_hooks(void) { static int count; - if (count++ >= 100 && limit && file) { - struct stat s; - count = 0; - if (fstat(fileno(file), &s) < 0) { - VLOG_WARN("cannot fstat leak checker log file: %s", - strerror(errno)); - return; - } - if (s.st_size > limit) { - VLOG_WARN("leak checker log file size exceeded limit"); + if (file) { + if (ferror(file)) { + VLOG_WARN("error writing leak checker log file"); leak_checker_stop(); return; } + + if (count++ >= 100 && limit) { + struct stat s; + count = 0; + if (fstat(fileno(file), &s) < 0) { + VLOG_WARN("cannot fstat leak checker log file: %s", + strerror(errno)); + return; + } + if (s.st_size > limit) { + VLOG_WARN("leak checker log file size exceeded limit"); + leak_checker_stop(); + return; + } + } } if (file) { set_hooks(&our_hooks);