changeset 94:0483ca64eb6b

Enable writelogreader to handle zero-length records
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 07 Feb 2016 18:25:45 +0000
parents c176114fad50
children c00c0af1efd2
files src/formats/writelog.rs
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/formats/writelog.rs	Sun Feb 07 18:25:25 2016 +0000
+++ b/src/formats/writelog.rs	Sun Feb 07 18:25:45 2016 +0000
@@ -200,8 +200,12 @@
                 Err(e) => return Err(e),
                 Ok(s) => {
                     if s == 0 {
-                        return Err(io::Error::new(io::ErrorKind::InvalidData,
-                                                  "Could not read enough data"));
+                        if len > 0 {
+                            return Err(io::Error::new(io::ErrorKind::InvalidData,
+                                                      "Could not read enough data"));
+                        } else {
+                            return Ok(0)
+                        }
                     } else if off + s < len {
                         off += s;
                     } else {