aquatic http load test: add option for closing conn after response

This commit is contained in:
Joakim Frostegård 2020-08-02 18:10:19 +02:00
parent f9d85117b1
commit 8a3f3fa330
2 changed files with 8 additions and 2 deletions

View file

@ -18,6 +18,7 @@ pub struct Config {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct NetworkConfig {
pub close_connection_after_response: bool,
pub connection_creation_interval: usize,
pub poll_timeout_microseconds: u64,
pub poll_event_capacity: usize,
@ -59,6 +60,7 @@ impl Default for Config {
impl Default for NetworkConfig {
fn default() -> Self {
Self {
close_connection_after_response: false,
connection_creation_interval: 40,
poll_timeout_microseconds: 47,
poll_event_capacity: 1024,

View file

@ -48,6 +48,7 @@ impl Connection {
pub fn read_response(
&mut self,
config: &Config,
state: &LoadTestState,
) -> bool { // bool = remove connection
loop {
@ -93,7 +94,7 @@ impl Connection {
self.bytes_read = 0;
self.can_send = true;
break false;
break config.network.close_connection_after_response;
},
Err(err) => {
eprintln!(
@ -218,7 +219,10 @@ pub fn run_socket_thread(
let token = event.token();
if let Some(connection) = connections.get_mut(&token.0){
let remove_connection = connection.read_response(&state);
let remove_connection = connection.read_response(
config,
&state
);
if remove_connection {
connections.remove(&token.0);