equal
deleted
inserted
replaced
22 } |
22 } |
23 |
23 |
24 fn recover(&mut self) -> bool { |
24 fn recover(&mut self) -> bool { |
25 self.is_recovering = match parser::malformed_message(&self.buf[..]) { |
25 self.is_recovering = match parser::malformed_message(&self.buf[..]) { |
26 Ok((tail, ())) => { |
26 Ok((tail, ())) => { |
27 self.buf.consume(self.buf.len() - tail.len()); |
27 let length = tail.len(); |
|
28 self.buf.consume(self.buf.len() - length); |
28 false |
29 false |
29 } |
30 } |
30 _ => { |
31 _ => { |
31 self.buf.consume(self.buf.len()); |
32 self.buf.consume(self.buf.len()); |
32 true |
33 true |
48 if !self.is_recovering { |
49 if !self.is_recovering { |
49 while !self.buf.is_empty() { |
50 while !self.buf.is_empty() { |
50 match parser::message(&self.buf[..]) { |
51 match parser::message(&self.buf[..]) { |
51 Ok((tail, message)) => { |
52 Ok((tail, message)) => { |
52 messages.push(message); |
53 messages.push(message); |
53 self.buf.consume(self.buf.len() - tail.len()); |
54 let length = tail.len(); |
|
55 self.buf.consume(self.buf.len() - length); |
54 } |
56 } |
55 Err(nom::Err::Incomplete(_)) => break, |
57 Err(nom::Err::Incomplete(_)) => break, |
56 Err(nom::Err::Failure(e)) | Err(nom::Err::Error(e)) => { |
58 Err(nom::Err::Failure(e)) | Err(nom::Err::Error(e)) => { |
57 debug!("Invalid message: {:?}", e); |
59 debug!("Invalid message: {:?}", e); |
58 if !self.recover() || self.buf.is_empty() { |
60 if !self.recover() || self.buf.is_empty() { |