From ef32cb95b1ed8bba0a0a46514c74070b516f50ef Mon Sep 17 00:00:00 2001 From: Lee Verberne Date: Tue, 2 Nov 2010 11:58:22 -0700 Subject: [PATCH] scribe_tail: fix infinite loop on log rotate scribe_tail was using the results from stat() rather than fstat() to detect file truncation, resulting in a false positive when filename is changed to point to a new, empty file. scribe_tail would then rewind the open file (not filename) and replay the log repeatedly. This changes scribe_tail to use the results from fstat() on the open file to detect truncation. --- examples/scribe_tail | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/scribe_tail b/examples/scribe_tail index cc75ebb1..332d3d16 100755 --- a/examples/scribe_tail +++ b/examples/scribe_tail @@ -169,7 +169,7 @@ def do_tail(client, filename): except OSError: st_results = fd_results - if st_results.st_size < where: + if fd_results.st_size < where: logger.info('%s was truncated. Jump back to 0.', filename) fd.seek(0) elif st_results.st_ino == fd_results.st_ino: @@ -347,4 +347,4 @@ if __name__ == '__main__': main() except KeyboardInterrupt: logger.info('Exiting on KeyboardInterrupt.') - sys.exit() \ No newline at end of file + sys.exit()