summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Aaron Murphy <mmstickman@gmail.com>2017-01-13 20:11:54 -0500
committerMichael Aaron Murphy <mmstickman@gmail.com>2017-01-13 20:11:54 -0500
commit9ba7f415677c6769efde3734d35a0eea85bc6bf0 (patch)
tree6706640061c67aac9afd589c83783e8f6aeb3580
parent7dc92f645fa9b106a9ea351ad6717b83aa51d376 (diff)
0.10.2: Quick Fix0.10.2
Removed unnecessary println's that were used for debugging.
-rw-r--r--Cargo.lock15
-rw-r--r--Cargo.toml2
-rw-r--r--src/execute/child.rs6
-rw-r--r--src/execute/exec_commands.rs5
-rw-r--r--src/execute/exec_inputs.rs7
-rw-r--r--src/execute/pipe.rs4
-rw-r--r--src/execute/receive.rs2
-rw-r--r--src/filepaths.rs13
-rw-r--r--src/main.rs1
9 files changed, 32 insertions, 23 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 9daffe5..2045924 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
[root]
name = "parallel"
-version = "0.10.1"
+version = "0.10.2"
dependencies = [
"arrayvec 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -8,7 +8,7 @@ dependencies = [
"permutate 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sys-info 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"wait-timeout 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -72,6 +72,11 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "redox_syscall"
+version = "0.1.16"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "smallvec"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -86,11 +91,12 @@ dependencies = [
[[package]]
name = "time"
-version = "0.1.35"
+version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -122,9 +128,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum num_cpus 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a225d1e2717567599c24f88e49f00856c6e825a12125181ee42c4257e3688d39"
"checksum odds 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)" = "c3df9b730298cea3a1c3faa90b7e2f9df3a9c400d0936d6015e6165734eefcba"
"checksum permutate 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b4ba980af238a6d6fcc0df53fe0d7920376bc4ce2c6ce298992891a230b47a8"
+"checksum redox_syscall 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd35cc9a8bdec562c757e3d43c1526b5c6d2653e23e2315065bc25556550753"
"checksum smallvec 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3c84984c278afe61a46e19868e8b23e2ee3be5b3cc6dea6edad4893bc6c841"
"checksum sys-info 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "246f8bbb443ae0026c92266c26d997d04634c8b44c3baff9fa3bff445b40878c"
-"checksum time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7ec6d62a20df54e07ab3b78b9a3932972f4b7981de295563686849eb3989af"
+"checksum time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "211b63c112206356ef1ff9b19355f43740fc3f85960c598a93d3a3d3ba7beade"
"checksum wait-timeout 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e8ab44ea5707ff5261a802e8be19697a2e342ecc55409b062c285fc4f624d05"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
diff --git a/Cargo.toml b/Cargo.toml
index eab8684..ed73b67 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "parallel"
-version = "0.10.1"
+version = "0.10.2"
authors = ["Michael Aaron Murphy <mmstickman@gmail.com>"]
license = "MIT"
description = "Command-line CPU load balancer for executing jobs in parallel"
diff --git a/src/execute/child.rs b/src/execute/child.rs
index b44170b..02c60e8 100644
--- a/src/execute/child.rs
+++ b/src/execute/child.rs
@@ -9,15 +9,15 @@ use super::pipe::disk::output as pipe_output;
use super::pipe::disk::State;
pub fn handle_child(mut child: Child, output: &Sender<State>, flags: u16, job_id: usize, input: String,
- has_timeout: bool, timeout: Duration, base: &str) -> (Timespec, Timespec, i32, i32)
+ has_timeout: bool, timeout: Duration, base: &str, buffer: &mut [u8]) -> (Timespec, Timespec, i32, i32)
{
let start_time = get_time();
if has_timeout && child.wait_timeout(timeout).unwrap().is_none() {
let _ = child.kill();
- pipe_output(&mut child, job_id, input, output, flags & QUIET_MODE != 0, base);
+ pipe_output(&mut child, job_id, input, output, flags & QUIET_MODE != 0, base, buffer);
(start_time, get_time(), -1, 15)
} else {
- pipe_output(&mut child, job_id, input, output, flags & QUIET_MODE != 0, base);
+ pipe_output(&mut child, job_id, input, output, flags & QUIET_MODE != 0, base, buffer);
match child.wait() {
Ok(status) => match status.code() {
Some(exit) => (start_time, get_time(), exit, 0),
diff --git a/src/execute/exec_commands.rs b/src/execute/exec_commands.rs
index a7f1bf8..accf6fd 100644
--- a/src/execute/exec_commands.rs
+++ b/src/execute/exec_commands.rs
@@ -37,11 +37,12 @@ impl ExecCommands {
let has_timeout = self.timeout != Duration::from_millis(0);
let mut input = String::with_capacity(64);
let mut id_buffer = [0u8; 64];
-
+ let mut job_buffer = [0u8; 64];
let mut total_buffer = [0u8; 64];
let truncate = self.num_inputs.numtoa(10, &mut total_buffer);
let job_total = &total_buffer[0..truncate];
+
while let Some(job_id) = self.inputs.try_next(&mut input) {
if self.flags & VERBOSE_MODE != 0 {
verbose::processing_task(&stdout, job_id+1, self.num_inputs, &input);
@@ -61,7 +62,7 @@ impl ExecCommands {
let (start_time, end_time, exit_value, signal) = match command.exec(command_buffer) {
Ok(child) => {
handle_child(child, &self.output_tx, self.flags, job_id, input.clone(), has_timeout, self.timeout,
- &self.tempdir)
+ &self.tempdir, &mut job_buffer)
},
Err(cmd_err) => {
let mut stderr = stderr.lock();
diff --git a/src/execute/exec_inputs.rs b/src/execute/exec_inputs.rs
index ab38a64..0ce47c9 100644
--- a/src/execute/exec_inputs.rs
+++ b/src/execute/exec_inputs.rs
@@ -28,8 +28,9 @@ impl ExecInputs {
let stdout = io::stdout();
let stderr = io::stderr();
- let has_timeout = self.timeout != Duration::from_millis(0);
- let mut input = String::with_capacity(64);
+ let has_timeout = self.timeout != Duration::from_millis(0);
+ let mut input = String::with_capacity(64);
+ let mut id_buffer = [0u8; 64];
while let Some(job_id) = self.inputs.try_next(&mut input) {
if flags & arguments::VERBOSE_MODE != 0 {
@@ -46,7 +47,7 @@ impl ExecInputs {
let (start_time, end_time, exit_value, signal) = match command::get_command_output(&input, flags) {
Ok(child) => {
handle_child(child, &self.output_tx, flags, job_id, input.clone(), has_timeout, self.timeout,
- &self.tempdir)
+ &self.tempdir, &mut id_buffer)
},
Err(why) => {
let mut stderr = stderr.lock();
diff --git a/src/execute/pipe.rs b/src/execute/pipe.rs
index e76f18d..878e274 100644
--- a/src/execute/pipe.rs
+++ b/src/execute/pipe.rs
@@ -20,9 +20,9 @@ pub mod disk {
/// Sends messages received by a `Child` process's standard output and error and sends them
/// to be handled by the grouped output channel.
pub fn output(child: &mut Child, job_id: usize, name: String, output_tx: &Sender<State>, quiet: bool,
- base: &str)
+ base: &str, buffer: &mut [u8])
{
- let (_, stdout_path, stderr_path) = filepaths::new_job(base, job_id);
+ let (_, stdout_path, stderr_path) = filepaths::new_job(base, job_id, buffer);
let mut stdout_file = File::create(stdout_path).expect("unable to create job stdout file");
let mut stderr_file = File::create(stderr_path).expect("unable to create job stderr file");
diff --git a/src/execute/receive.rs b/src/execute/receive.rs
index b2b9174..6395efc 100644
--- a/src/execute/receive.rs
+++ b/src/execute/receive.rs
@@ -100,7 +100,7 @@ pub fn receive_messages(input_rx: Receiver<State>, args: Args, base: &str, proce
// A buffer for converting job ID's into a byte array representation of a string.
let mut id_buffer = [0u8; 64];
// Generates the stdout and stderr paths, along with a truncation value to truncate the job ID from the paths.
- let (truncate_size, mut stdout_path, mut stderr_path) = filepaths::new_job(base, counter);
+ let (truncate_size, mut stdout_path, mut stderr_path) = filepaths::new_job(base, counter, &mut id_buffer);
// If the joblog parameter was passed, open the file for writing.
let mut joblog = args.joblog.map(|path| {
job_counter = 0;
diff --git a/src/filepaths.rs b/src/filepaths.rs
index f85f86f..ec1c3a7 100644
--- a/src/filepaths.rs
+++ b/src/filepaths.rs
@@ -15,18 +15,19 @@ pub fn base() -> Option<PathBuf> {
})
}
-pub fn new_job(base: &str, id: usize) -> (usize, String, String) {
- let id = id.to_string();
+pub fn new_job(base: &str, id: usize, buffer: &mut [u8]) -> (usize, String, String) {
let mut stdout = String::from(base) + "/stdout_";
let mut stderr = String::from(base) + "/stderr_";
let truncate_value = stdout.len();
- stdout.push_str(&id);
- stderr.push_str(&id);
- println!("stdout: '{}'", stdout);
+ let length = id.numtoa(10, buffer);
+ for byte in &buffer[0..length] {
+ stdout.push(*byte as char);
+ stderr.push(*byte as char);
+ }
(truncate_value, stdout, stderr)
}
-pub fn next_job_path(id: usize, truncate: usize, buffer: &mut [u8; 64], stdout: &mut String, stderr: &mut String) {
+pub fn next_job_path(id: usize, truncate: usize, buffer: &mut [u8], stdout: &mut String, stderr: &mut String) {
stdout.truncate(truncate);
stderr.truncate(truncate);
let length = id.numtoa(10, buffer);
diff --git a/src/main.rs b/src/main.rs
index 7fc41cb..4c52873 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -82,7 +82,6 @@ fn main() {
exit(1);
}
};
- println!("base_path: '{}'", base_path);
let mut unprocessed_path = base.clone();
let mut processed_path = base.clone();