r23181: prevent attempts to reopen the connection twice at the same time
authorAndrew Tridgell <tridge@samba.org>
Tue, 29 May 2007 08:22:45 +0000 (08:22 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:53:01 +0000 (14:53 -0500)
source/torture/raw/lockbench.c
source/torture/raw/openbench.c

index e929218ead2f92b30b9846b70b6d833909c9541f..af0c65b6a415bad76db5a0215f17b931b2644e8e 100644 (file)
@@ -54,6 +54,7 @@ struct benchlock_state {
        int lastcount;
        struct smbcli_request *req;
        struct smb_composite_connect reconnect;
+       struct timed_event *te;
 
        /* these are used for reconnections */
        int dest_port;
@@ -148,9 +149,10 @@ static void reopen_connection_complete(struct composite_context *ctx)
 
        status = smb_composite_connect_recv(ctx, state->mem_ctx);
        if (!NT_STATUS_IS_OK(status)) {
-               event_add_timed(state->ev, state->mem_ctx, 
-                               timeval_current_ofs(1,0), 
-                               reopen_connection, state);
+               talloc_free(state->te);
+               state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                           timeval_current_ofs(1,0), 
+                                           reopen_connection, state);
                return;
        }
 
@@ -218,9 +220,10 @@ static void lock_completion(struct smbcli_request *req)
                        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);
+                       talloc_free(state->te);
+                       state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                                   timeval_current_ofs(1,0), 
+                                                   reopen_connection, state);
                } else {
                        DEBUG(0,("Lock failed - %s\n", nt_errstr(status)));
                        lock_failed++;
@@ -256,9 +259,10 @@ static void echo_completion(struct smbcli_request *req)
                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);
+               talloc_free(state->te);
+               state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                           timeval_current_ofs(1,0), 
+                                           reopen_connection, state);
        }
 }
 
index fe01f1f5e29a0d146ba21b9832851a454be9ad85..f956d84234e3a925e25dd3b100e1c44955b42981 100644 (file)
@@ -57,6 +57,7 @@ struct benchopen_state {
        struct smbcli_request *req_open;
        struct smbcli_request *req_close;
        struct smb_composite_connect reconnect;
+       struct timed_event *te;
 
        /* these are used for reconnections */
        int dest_port;
@@ -81,9 +82,10 @@ static void reopen_connection_complete(struct composite_context *ctx)
 
        status = smb_composite_connect_recv(ctx, state->mem_ctx);
        if (!NT_STATUS_IS_OK(status)) {
-               event_add_timed(state->ev, state->mem_ctx, 
-                               timeval_current_ofs(1,0), 
-                               reopen_connection, state);
+               talloc_free(state->te);
+               state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                           timeval_current_ofs(1,0), 
+                                           reopen_connection, state);
                return;
        }
 
@@ -210,9 +212,10 @@ static void open_completed(struct smbcli_request *req)
                state->cli = 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);
+               talloc_free(state->te);
+               state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                           timeval_current_ofs(1,0), 
+                                           reopen_connection, state);
                return;
        }
 
@@ -262,9 +265,10 @@ static void close_completed(struct smbcli_request *req)
                state->cli = 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);
+               talloc_free(state->te);
+               state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                           timeval_current_ofs(1,0), 
+                                           reopen_connection, state);
                return;
        }
 
@@ -289,9 +293,10 @@ static void echo_completion(struct smbcli_request *req)
                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);
+               talloc_free(state->te);
+               state->te = event_add_timed(state->ev, state->mem_ctx, 
+                                           timeval_current_ofs(1,0), 
+                                           reopen_connection, state);
        }
 }