Skip to content

Commit ba002fe

Browse files
committed
fix hanging stream if line not matching filter
1 parent 2c8f1a9 commit ba002fe

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/repository/filerepo.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,24 @@ impl FileLogStream {
108108
fn next_line(&mut self) -> Poll<Option<Result<StreamEntry, ApplicationError>>> {
109109
let lines_iter = self.lines_iter.as_mut();
110110
let lines_iter = lines_iter.unwrap(); // should panic, if this is called with None option
111-
let nextline = lines_iter.next();
112-
match nextline {
113-
Some(lineresult) => match lineresult {
111+
while let Some(nextline) = lines_iter.next() {
112+
match nextline {
114113
Ok(line) => {
115114
let parsed_line =
116115
FileLogStream::apply_pattern(&line, &self.line_pattern, self.year);
117116
if !self.logfilter.matches(&parsed_line) {
118-
Poll::Pending
117+
continue;
119118
} else {
120-
Poll::Ready(Some(Ok(StreamEntry::LogLine { line, parsed_line })))
119+
return Poll::Ready(Some(Ok(StreamEntry::LogLine { line, parsed_line })));
121120
}
122121
}
123122
Err(e) => {
124123
error!("Stream error: {:?}", e);
125-
Poll::Ready(None)
124+
break;
126125
}
127-
},
128-
None => Poll::Ready(None),
126+
}
129127
}
128+
Poll::Ready(None)
130129
}
131130
}
132131

tests/server_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ fn itest_get_source_content_api_with_logfilter() {
9797
.header("User-Agent", "Actix-web")
9898
.header("Accept", "*/*")
9999
.timeout(std::time::Duration::from_millis(1000));
100-
101100
support::http_request(req, StatusCode::OK).map(|s| {
102-
dbg!(&s);
103101
assert_eq!(
104102
s,
105103
r#"2019-01-01 08:00:02 DEBUG demo2line2
@@ -125,6 +123,7 @@ fn setup() -> Arc<ProcessHolder> {
125123
None => {
126124
let exe = support::binary("tentacle").unwrap();
127125
let process = std::process::Command::new(exe)
126+
// .arg("-vvv")
128127
.arg("--config=tests/integrationtests.yml")
129128
.spawn()
130129
.expect("Failed to run server");

0 commit comments

Comments
 (0)