From ba0424fddbfe4f38663dd5c7f7252f443c601489 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 14 May 2007 01:05:09 +0000 Subject: r22836: started adding auto-reconnect logic to lockbench. This needs to be made async. (This used to be commit 9e1ea3e09c80adb0b9809ee83e0c7b1ec9156e42) --- source4/torture/raw/lockbench.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'source4/torture/raw/lockbench.c') diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 3d02e0f5c4..1621139aa7 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -44,7 +44,9 @@ static int nprocs; static int lock_failed; struct benchlock_state { + struct event_context *ev; struct smbcli_state *cli; + int client_num; int fnum; int offset; int count; @@ -76,6 +78,33 @@ static void lock_send(struct benchlock_state *state) state->offset = (state->offset+1)%nprocs; } +/* + reopen dead connections + */ +static void reopen_connection(struct benchlock_state *state) +{ + do { + DEBUG(0,("reopening connection %u\n", state->client_num)); + } while (!torture_open_connection_ev(&state->cli, state->client_num, state->ev)); + + state->fnum = smbcli_open(state->cli->tree, FNAME, O_RDWR|O_CREAT, DENY_NONE); + if (state->fnum == -1) { + printf("Failed to open %s on connection %d\n", FNAME, state->client_num); + exit(1); + } + + state->lock[0].offset = state->offset; + state->io.lockx.in.ulock_cnt = 0; + state->req = smb_raw_lock_send(state->cli->tree, &state->io); + if (state->req == NULL) { + DEBUG(0,("Failed to setup lock\n")); + lock_failed++; + } + state->req->async.private = state; + state->req->async.fn = lock_completion; + state->offset = (state->offset+1)%nprocs; +} + /* called when a lock completes */ @@ -87,6 +116,9 @@ static void lock_completion(struct smbcli_request *req) if (!NT_STATUS_IS_OK(status)) { lock_failed++; DEBUG(0,("Lock failed - %s\n", nt_errstr(status))); + if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) { + reopen_connection(state); + } } else { state->count++; lock_send(state); @@ -114,6 +146,8 @@ BOOL torture_bench_lock(struct torture_context *torture) printf("Opening %d connections\n", nprocs); for (i=0;i