r26644: Janitorial: Pass resolve_context explicitly to various SMB functions, should...
[jelmer/samba4-debian.git] / source / torture / raw / openbench.c
index dcba73dfffc306d5f6fdf9801643b63344847bec..881f487cb061ae96ea334db8019a7a85ae03d7d9 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/cmdline/popt_common.h"
 #include "libcli/composite/composite.h"
 #include "libcli/smb_composite/smb_composite.h"
+#include "libcli/resolve/resolve.h"
 #include "param/param.h"
 
 #define BASEDIR "\\benchopen"
@@ -42,6 +43,7 @@ static int num_connected;
 static struct timed_event *report_te;
 
 struct benchopen_state {
+       struct torture_context *tctx;
        TALLOC_CTX *mem_ctx;
        struct event_context *ev;
        struct smbcli_state *cli;
@@ -116,26 +118,28 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te,
 
        state->te = NULL;
 
-       if (!torture_get_conn_index(state->client_num, state->mem_ctx, &host, &share)) {
+       if (!torture_get_conn_index(state->client_num, state->mem_ctx, state->tctx, &host, &share)) {
                DEBUG(0,("Can't find host/share for reconnect?!\n"));
                exit(1);
        }
 
        io->in.dest_host    = state->dest_host;
-       io->in.port         = state->dest_port;
+       io->in.dest_ports   = state->dest_port;
        io->in.called_name  = state->called_name;
        io->in.service      = share;
        io->in.service_type = state->service_type;
        io->in.credentials  = cmdline_credentials;
-       io->in.fallback_to_anonymous = False;
-       io->in.workgroup    = lp_workgroup(global_loadparm);
+       io->in.fallback_to_anonymous = false;
+       io->in.workgroup    = lp_workgroup(state->tctx->lp_ctx);
 
        /* kill off the remnants of the old connection */
        talloc_free(state->tree);
        state->tree = NULL;
        state->fnum = -1;
 
-       ctx = smb_composite_connect_send(io, state->mem_ctx, state->ev);
+       ctx = smb_composite_connect_send(io, state->mem_ctx, 
+                                        lp_resolve_context(state->tctx->lp_ctx), 
+                                        state->ev);
        if (ctx == NULL) {
                DEBUG(0,("Failed to setup async reconnect\n"));
                exit(1);
@@ -338,9 +342,9 @@ static void report_rate(struct event_context *ev, struct timed_event *te,
 /* 
    benchmark open calls
 */
-BOOL torture_bench_open(struct torture_context *torture)
+bool torture_bench_open(struct torture_context *torture)
 {
-       BOOL ret = True;
+       bool ret = true;
        TALLOC_CTX *mem_ctx = talloc_new(torture);
        int i;
        int timelimit = torture_setting_int(torture, "timelimit", 10);
@@ -348,7 +352,7 @@ BOOL torture_bench_open(struct torture_context *torture)
        struct event_context *ev = event_context_find(mem_ctx);
        struct benchopen_state *state;
        int total = 0, minops=0;
-       bool progress=False;
+       bool progress=false;
 
        progress = torture_setting_bool(torture, "progress", true);
        
@@ -358,11 +362,12 @@ BOOL torture_bench_open(struct torture_context *torture)
 
        printf("Opening %d connections\n", nprocs);
        for (i=0;i<nprocs;i++) {
+               state[i].tctx = torture;
                state[i].mem_ctx = talloc_new(state);
                state[i].client_num = i;
                state[i].ev = ev;
-               if (!torture_open_connection_ev(&state[i].cli, i, ev)) {
-                       return False;
+               if (!torture_open_connection_ev(&state[i].cli, i, torture, ev)) {
+                       return false;
                }
                talloc_steal(mem_ctx, state);
                state[i].tree = state[i].cli->tree;
@@ -438,5 +443,5 @@ BOOL torture_bench_open(struct torture_context *torture)
 
 failed:
        talloc_free(mem_ctx);
-       return False;
+       return false;
 }