From cc1e5b72dc0be79b872d4996a72e241236589245 Mon Sep 17 00:00:00 2001 From: "Brian L. Troutwine" Date: Mon, 11 Sep 2017 11:37:19 -0700 Subject: [PATCH] Bump to cernan 0.7.5 This release contains fixes for the overlong holding of file descriptors in a couple of spots inside of cernan: * 07d3fad0 :: drop unused structures after cernan boot * de747e12 :: drop deleted files from polling in file source The first change allows hopper to drop file descriptors opened as a part of cernan startup. The second change allows the file source to drop file descriptors as soon as the files are marked deleted. Previously we assumed that this could be avoided on the expectation of applications creating a new logfile. This assumption was not valid. Signed-off-by: Brian L. Troutwine --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/source/file/file_server.rs | 37 +++++++++++++-------------------- src/source/file/file_watcher.rs | 13 ++++-------- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bbfe99ca..9838a2fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "cernan" -version = "0.7.5-pre" +version = "0.7.5" dependencies = [ "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index dc965665..159b0d91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" name = "cernan" readme = "README.md" repository = "https://github.com/postmates/cernan" -version = "0.7.5-pre" +version = "0.7.5" [[bin]] name = "cernan" diff --git a/src/source/file/file_server.rs b/src/source/file/file_server.rs index f03ebacc..ddd3edb4 100644 --- a/src/source/file/file_server.rs +++ b/src/source/file/file_server.rs @@ -118,28 +118,21 @@ impl Source for FileServer { // line polling for (path, mut watcher) in fp_map.drain() { let mut lines_read: usize = 0; - loop { - match watcher.read_line(&mut buffer) { - Ok(sz) => { - if sz > 0 { - lines_read += 1; - lines.push( - metric::LogLine::new( - path.to_str().expect("not a valid path"), - &buffer, - ).overlay_tags_from_map(&self.tags), - ); - buffer.clear(); - } else { - break; - } - if lines_read > self.max_lines_read { - break; - } - } - _ => { - break; - } + while let Ok(sz) = watcher.read_line(&mut buffer) { + if sz > 0 { + lines_read += 1; + lines.push( + metric::LogLine::new( + path.to_str().expect("not a valid path"), + &buffer, + ).overlay_tags_from_map(&self.tags), + ); + buffer.clear(); + } else { + break; + } + if lines_read > self.max_lines_read { + break; } } report_full_telemetry( diff --git a/src/source/file/file_watcher.rs b/src/source/file/file_watcher.rs index 4372c49b..f688fffb 100644 --- a/src/source/file/file_watcher.rs +++ b/src/source/file/file_watcher.rs @@ -96,10 +96,8 @@ impl FileWatcher { /// up to some maximum but unspecified amount of time. `read_line` will open /// a new file handler at need, transparently to the caller. pub fn read_line(&mut self, mut buffer: &mut String) -> io::Result { - if self.reopen { - if self.file_id() != self.file_id { - self.open_at_start(); - } + if self.reopen && self.file_id() != self.file_id { + self.open_at_start(); } if let Some(ref mut reader) = self.reader { // match here on error, if metadata doesn't match up open_at_start @@ -115,11 +113,8 @@ impl FileWatcher { Ok(buffer.len()) } Err(e) => { - match e.kind() { - io::ErrorKind::NotFound => { - self.reopen = true; - } - _ => {} + if let io::ErrorKind::NotFound = e.kind() { + self.reopen = true; } Err(e) }