Restore the original --server and --server_name options.

This commit is contained in:
Joseph Kong 2016-01-22 22:40:01 -08:00
parent 83fef49f59
commit 941bc9558f
4 changed files with 43 additions and 17 deletions

View File

@ -86,22 +86,32 @@ conn_add_servers(void)
void void
conn_init(Conn *conn) conn_init(Conn *conn)
{ {
int len; if (param.servers) {
int len = strlen(srvcurrent);
len = strlen(srvcurrent);
conn->hostname = srvcurrent; conn->hostname = srvcurrent;
conn->hostname_len = len; conn->hostname_len = len;
conn->fqdname = conn->hostname;
conn->fqdname_len = conn->hostname_len;
srvcurrent += len + 1; srvcurrent += len + 1;
if (srvcurrent >= srvend) if (srvcurrent >= srvend)
srvcurrent = srvbase; srvcurrent = srvbase;
} else if (param.server_name) {
conn->hostname = param.server;
conn->hostname_len = strlen(param.server);
conn->fqdname = param.server_name;
conn->fqdname_len = strlen(param.server_name);
} else {
conn->hostname = param.server;
conn->hostname_len = strlen(param.server);
conn->fqdname = conn->hostname;
conn->fqdname_len = conn->hostname_len;
}
conn->port = param.port; conn->port = param.port;
conn->sd = -1; conn->sd = -1;
conn->myport = -1; conn->myport = -1;
conn->line.iov_base = conn->line_buf; conn->line.iov_base = conn->line_buf;
conn->fqdname = conn->hostname;
conn->fqdname_len = conn->hostname_len;
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (param.use_ssl) { if (param.use_ssl) {

View File

@ -965,6 +965,9 @@ core_init(void)
if (param.servers) if (param.servers)
conn_add_servers(); conn_add_servers();
else if (param.server)
core_addr_intern(param.server, strlen(param.server), param.port);
if (param.runtime) { if (param.runtime) {
arg.l = 0; arg.l = 0;
timer_schedule(core_runtime_timer, arg, param.runtime); timer_schedule(core_runtime_timer, arg, param.runtime);

View File

@ -136,6 +136,8 @@ static struct option longopts[] = {
{"retry-on-failure", no_argument, &param.retry_on_failure, 1}, {"retry-on-failure", no_argument, &param.retry_on_failure, 1},
{"runtime", required_argument, (int *) &param.runtime, 0}, {"runtime", required_argument, (int *) &param.runtime, 0},
{"send-buffer", required_argument, (int *) &param.send_buffer_size, 0}, {"send-buffer", required_argument, (int *) &param.send_buffer_size, 0},
{"server", required_argument, (int *) &param.server, 0},
{"server-name", required_argument, (int *) &param.server_name, 0},
{"servers", required_argument, (int *) &param.servers, 0}, {"servers", required_argument, (int *) &param.servers, 0},
{"uri", required_argument, (int *) &param.uri, 0}, {"uri", required_argument, (int *) &param.uri, 0},
{"session-cookies", no_argument, (int *) &param.session_cookies, 1}, {"session-cookies", no_argument, (int *) &param.session_cookies, 1},
@ -175,9 +177,9 @@ usage(void)
"\t[--num-calls N] [--num-conns N] [--session-cookies]\n" "\t[--num-calls N] [--num-conns N] [--session-cookies]\n"
"\t[--period [d|u|e]T1[,T2]|[v]T1,D1[,T2,D2]...[,Tn,Dn]\n" "\t[--period [d|u|e]T1[,T2]|[v]T1,D1[,T2,D2]...[,Tn,Dn]\n"
"\t[--print-reply [header|body]] [--print-request [header|body]]\n" "\t[--print-reply [header|body]] [--print-request [header|body]]\n"
"\t[--rate X] [--recv-buffer N] [--retry-on-failure] " "\t[--rate X] [--recv-buffer N] [--retry-on-failure] [--send-buffer N]\n"
"[--send-buffer N]\n" "\t[--server S|--servers file] [--server-name S] [--port N] [--uri S] "
"\t<--servers file> [--port N] [--uri S] [--myaddr S]\n" "[--myaddr S]\n"
#ifdef HAVE_SSL #ifdef HAVE_SSL
"\t[--ssl] [--ssl-ciphers L] [--ssl-no-reuse]\n" "\t[--ssl] [--ssl-ciphers L] [--ssl-no-reuse]\n"
"\t[--ssl-certificate file] [--ssl-key file]\n" "\t[--ssl-certificate file] [--ssl-key file]\n"
@ -635,7 +637,11 @@ main(int argc, char **argv)
prog_name, optarg); prog_name, optarg);
exit(1); exit(1);
} }
} else if (flag == &param.servers) } else if (flag == &param.server)
param.server = optarg;
else if (flag == &param.server_name)
param.server_name = optarg;
else if (flag == &param.servers)
param.servers = optarg; param.servers = optarg;
#ifdef HAVE_SSL #ifdef HAVE_SSL
else if (flag == &param.ssl_cipher_list) else if (flag == &param.ssl_cipher_list)
@ -974,13 +980,16 @@ main(int argc, char **argv)
} }
} }
if (param.servers == NULL) { if (param.server != NULL && param.servers != NULL) {
fprintf(stderr, fprintf(stderr,
"%s: must specify --servers\n", "%s: --server S or --servers file\n",
prog_name); prog_name);
exit(-1); exit(-1);
} }
if (param.server == NULL && param.servers == NULL)
param.server = "localhost";
#ifdef HAVE_SSL #ifdef HAVE_SSL
if (param.use_ssl) { if (param.use_ssl) {
char buf[1024]; char buf[1024];
@ -1131,6 +1140,10 @@ main(int argc, char **argv)
if (param.runtime > 0) if (param.runtime > 0)
printf(" --runtime=%g", param.runtime); printf(" --runtime=%g", param.runtime);
printf(" --client=%u/%u", param.client.id, param.client.num_clients); printf(" --client=%u/%u", param.client.id, param.client.num_clients);
if (param.server)
printf(" --server=%s", param.server);
if (param.server_name)
printf(" --server_name=%s", param.server_name);
if (param.servers) if (param.servers)
printf(" --servers=%s", param.servers); printf(" --servers=%s", param.servers);
if (param.port) if (param.port)

View File

@ -156,7 +156,7 @@ typedef struct Cmdline_Params
u_int num_reqs; /* # of user requests per session */ u_int num_reqs; /* # of user requests per session */
Time think_time; /* user think time between requests */ Time think_time; /* user think time between requests */
} }
wsesspage; /* XXX Currently broken */ wsesspage;
struct struct
{ {
u_int num_sessions; /* # of user-sessions */ u_int num_sessions; /* # of user-sessions */