From a085d682e664ff76ec33d65c71bcbcdc99697e74 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 May 2007 12:21:29 +0000 Subject: r23142: added error checking and reconnect on echo replies (This used to be commit 0d47efe6d6d1738183c59942a077faaf1c77f004) --- source4/torture/raw/lockbench.c | 29 +++++++++++++++++++++++++---- source4/torture/raw/openbench.c | 29 +++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 8 deletions(-) (limited to 'source4/torture/raw') diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 901b7dee7e..2197ccc010 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -244,6 +244,22 @@ static void lock_completion(struct smbcli_request *req) } +static void echo_completion(struct smbcli_request *req) +{ + struct benchlock_state *state = talloc_get_type(req->async.private, + struct benchlock_state); + NTSTATUS status = smbcli_request_simple_recv(req); + if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { + talloc_free(state->tree); + state->tree = NULL; + num_connected--; + DEBUG(0,("reopening connection to %s\n", state->dest_host)); + event_add_timed(state->ev, state->mem_ctx, + timeval_current_ofs(1,0), + reopen_connection, state); + } +} + static void report_rate(struct event_context *ev, struct timed_event *te, struct timeval t, void *private_data) { @@ -258,16 +274,21 @@ static void report_rate(struct event_context *ev, struct timed_event *te, fflush(stdout); event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state); + if (!state[i].tree) { + return; + } + /* send an echo on each interface to ensure it stays alive - this helps with IP takeover */ for (i=0;isession->transport, &p); - } + req = smb_raw_echo_send(state[i].tree->session->transport, &p); + req->async.private = state; + req->async.fn = echo_completion; } } diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index 4ca7781754..b99259c618 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -284,6 +284,22 @@ static void next_operation(struct benchopen_state *state) } } +static void echo_completion(struct smbcli_request *req) +{ + struct benchopen_state *state = talloc_get_type(req->async.private, + struct benchopen_state); + NTSTATUS status = smbcli_request_simple_recv(req); + if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { + talloc_free(state->tree); + state->tree = NULL; + num_connected--; + DEBUG(0,("reopening connection to %s\n", state->dest_host)); + event_add_timed(state->ev, state->mem_ctx, + timeval_current_ofs(1,0), + reopen_connection, state); + } +} + static void report_rate(struct event_context *ev, struct timed_event *te, struct timeval t, void *private_data) { @@ -298,16 +314,21 @@ static void report_rate(struct event_context *ev, struct timed_event *te, fflush(stdout); event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state); + if (!state[i].tree) { + return; + } + /* send an echo on each interface to ensure it stays alive - this helps with IP takeover */ for (i=0;isession->transport, &p); - } + req = smb_raw_echo_send(state[i].tree->session->transport, &p); + req->async.private = state; + req->async.fn = echo_completion; } } -- cgit