#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"
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;
struct timed_event *te;
/* these are used for reconnections */
- int dest_port;
+ const char **dest_ports;
const char *dest_host;
const char *called_name;
const char *service_type;
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_ports;
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);
+ lp_smbcli_options(state->tctx->lp_ctx, &io->in.options);
/* 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);
/*
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);
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);
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;
state[i].dest_host = talloc_strdup(state[i].mem_ctx,
state[i].cli->tree->session->transport->socket->hostname);
- state[i].dest_port = state[i].cli->tree->session->transport->socket->port;
+ state[i].dest_ports = talloc_array(state[i].mem_ctx,
+ const char *, 2);
+ state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
+ "%u", state[i].cli->tree->session->transport->socket->port);
+ state[i].dest_ports[1] = NULL;
state[i].called_name = talloc_strdup(state[i].mem_ctx,
state[i].cli->tree->session->transport->called.name);
state[i].service_type = talloc_strdup(state[i].mem_ctx,
failed:
talloc_free(mem_ctx);
- return False;
+ return false;
}