This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#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();
+ 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);
static void echo_completion(struct smbcli_request *req)
{
- struct benchopen_state *state = talloc_get_type(req->async.private,
- struct benchopen_state);
+ struct benchopen_state *state = (struct benchopen_state *)req->async.private;
NTSTATUS status = smbcli_request_simple_recv(req);
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) ||
NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT)) {
p.in.size = 0;
p.in.data = NULL;
req = smb_raw_echo_send(state[i].tree->session->transport, &p);
- req->async.private = state;
+ req->async.private = &state[i];
req->async.fn = echo_completion;
}
}
/*
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);
- nprocs = lp_parm_int(-1, "torture", "nprocs", 4);
+ nprocs = torture_setting_int(torture, "nprocs", 4);
state = talloc_zero_array(mem_ctx, struct benchopen_state, nprocs);
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;
}