Skip to content

Commit

Permalink
Line-buffered indexed_log
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Apr 3, 2018
1 parent e509f49 commit 6caa06c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions indexed_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct Deployment<'a> {
index: &'a mut Index,
id: String,
global_segment: String,
log: File,
log: io::LineWriter<File>,
errors: Vec<Error>,
done: bool,
}
Expand All @@ -97,7 +97,7 @@ pub struct Role<'a: 'b, 'b> {
deployment: &'b mut Deployment<'a>,
role: &'b str,
segment: String,
log: File,
log: io::LineWriter<File>,
err: Option<io::Error>,
full_role: bool,
}
Expand Down Expand Up @@ -198,7 +198,7 @@ impl Index {
index: self,
id: id.to_string(),
global_segment: segment,
log: log,
log: io::LineWriter::new(log),
errors: errors,
done: !start,
};
Expand All @@ -214,7 +214,7 @@ impl<'a> Deployment<'a> {
{
let time = now_utc().rfc3339().to_string();
let pos = if self.index.stdout { 0 } else {
match self.log.seek(SeekFrom::End(0)) {
match self.log.get_mut().seek(SeekFrom::End(0)) {
Ok(x) => x,
Err(e) => {
self.errors.push(Error::WriteGlobal(e));
Expand Down Expand Up @@ -357,7 +357,7 @@ impl<'a> Deployment<'a> {
deployment: self,
role: name,
segment: segment,
log: log_file,
log: io::LineWriter::new(log_file),
full_role: start,
err: None,
};
Expand Down Expand Up @@ -439,7 +439,7 @@ impl<'a> Drop for Deployment<'a> {
impl<'a, 'b> Role<'a, 'b> {
fn entry(&mut self, marker: Marker) {
let pos = if self.deployment.index.stdout { 0 } else {
match self.log.seek(SeekFrom::End(0)) {
match self.log.get_mut().seek(SeekFrom::End(0)) {
Ok(x) => x,
Err(e) => {
add_err(&mut self.err, Some(e));
Expand Down Expand Up @@ -521,10 +521,10 @@ impl<'a, 'b, 'c> Action<'a, 'b, 'c> {
pub fn redirect_command(&mut self, cmd: &mut Command)
-> Result<(), Error>
{
let file = try!(nix::unistd::dup(self.role.log.as_raw_fd())
let file = try!(nix::unistd::dup(self.role.log.get_ref().as_raw_fd())
.map_err(|e| Error::Dup(e)));
cmd.stdout(unsafe { Stdio::from_raw_fd(file) });
let file = try!(nix::unistd::dup(self.role.log.as_raw_fd())
let file = try!(nix::unistd::dup(self.role.log.get_ref().as_raw_fd())
.map_err(|e| Error::Dup(e)));
cmd.stderr(unsafe { Stdio::from_raw_fd(file) });
Ok(())
Expand Down

0 comments on commit 6caa06c

Please sign in to comment.