SecretStore: do not send init if session has finished/failed instantly (#7397)

This commit is contained in:
Svyatoslav Nikolsky 2018-01-10 13:35:23 +03:00 committed by Afri Schoedon
parent df5d27d516
commit d360074323

View File

@ -200,22 +200,13 @@ impl<Executor, Transport> JobSession<Executor, Transport> where Executor: JobExe
return Err(Error::InvalidStateForRequest); return Err(Error::InvalidStateForRequest);
} }
// send requests to slave nodes // result from self
let mut waits_for_self = false;
let active_data = ActiveJobSessionData { let active_data = ActiveJobSessionData {
requests: nodes, requests: nodes.clone(),
rejects: BTreeSet::new(), rejects: BTreeSet::new(),
responses: BTreeMap::new(), responses: BTreeMap::new(),
}; };
for node in &active_data.requests { let waits_for_self = active_data.requests.contains(&self.meta.self_node_id);
if node != &self.meta.self_node_id {
self.transport.send_partial_request(&node, self.executor.prepare_partial_request(node, &active_data.requests)?)?;
} else {
waits_for_self = true;
}
}
// result from self
let self_response = if waits_for_self { let self_response = if waits_for_self {
let partial_request = self.executor.prepare_partial_request(&self.meta.self_node_id, &active_data.requests)?; let partial_request = self.executor.prepare_partial_request(&self.meta.self_node_id, &active_data.requests)?;
Some(self.executor.process_partial_request(partial_request)?) Some(self.executor.process_partial_request(partial_request)?)
@ -236,6 +227,13 @@ impl<Executor, Transport> JobSession<Executor, Transport> where Executor: JobExe
} }
} }
// send requests to save nodes. we only send requests if session is still active.
if self.data.state == JobSessionState::Active {
for node in nodes.iter().filter(|n| **n != self.meta.self_node_id) {
self.transport.send_partial_request(node, self.executor.prepare_partial_request(node, &nodes)?)?;
}
}
Ok(()) Ok(())
} }