r23142: added error checking and reconnect on echo replies
authorAndrew Tridgell <tridge@samba.org>
Fri, 25 May 2007 12:21:29 +0000 (12:21 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 25 May 2007 12:21:29 +0000 (12:21 +0000)
source/torture/raw/lockbench.c
source/torture/raw/openbench.c

index 901b7dee7efe8de8a0bfebb1f161337a278b4df4..2197ccc0100756081dbf1829c624bde164394d0a 100644 (file)
@@ -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;i<nprocs;i++) {
                struct smb_echo p;
-               p.in.repeat_count = 0;
+               struct smbcli_request *req;
+               p.in.repeat_count = 1;
                p.in.size = 0;
                p.in.data = NULL;
-               if (state[i].tree) {
-                       smb_raw_echo_send(state[i].tree->session->transport, &p);
-               }
+               req = smb_raw_echo_send(state[i].tree->session->transport, &p);
+               req->async.private = state;
+               req->async.fn      = echo_completion;
        }
 }
 
index 4ca77817547c6ae31628437b1eac321262d93246..b99259c618a081b3d5b07019085c4528874a71b4 100644 (file)
@@ -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;i<nprocs;i++) {
                struct smb_echo p;
-               p.in.repeat_count = 0;
+               struct smbcli_request *req;
+               p.in.repeat_count = 1;
                p.in.size = 0;
                p.in.data = NULL;
-               if (state[i].tree) {
-                       smb_raw_echo_send(state[i].tree->session->transport, &p);
-               }
+               req = smb_raw_echo_send(state[i].tree->session->transport, &p);
+               req->async.private = state;
+               req->async.fn      = echo_completion;
        }
 }