Merge pull request #36 from josephjkong/jk_master_fix_server
Restore the original --server and --server_name options
This commit is contained in:
commit
efb9e6c86a
122
src/conn.c
122
src/conn.c
@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
httperf -- a tool for measuring web server performance
|
* httperf -- a tool for measuring web server performance
|
||||||
Copyright 2000-2007 Hewlett-Packard Company
|
* Copyright 2000-2007 Hewlett-Packard Company
|
||||||
|
*
|
||||||
This file is part of httperf, a web server performance measurment
|
* This file is part of httperf, a web server performance measurment
|
||||||
tool.
|
* tool.
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
License, or (at your option) any later version.
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
In addition, as a special exception, the copyright holders give
|
* In addition, as a special exception, the copyright holders give
|
||||||
permission to link the code of this work with the OpenSSL project's
|
* permission to link the code of this work with the OpenSSL project's
|
||||||
"OpenSSL" library (or with modified versions of it that use the same
|
* "OpenSSL" library (or with modified versions of it that use the same
|
||||||
license as the "OpenSSL" library), and distribute linked combinations
|
* license as the "OpenSSL" library), and distribute linked combinations
|
||||||
including the two. You must obey the GNU General Public License in
|
* including the two. You must obey the GNU General Public License in
|
||||||
all respects for all of the code used other than "OpenSSL". If you
|
* all respects for all of the code used other than "OpenSSL". If you
|
||||||
modify this file, you may extend this exception to your version of the
|
* modify this file, you may extend this exception to your version of the
|
||||||
file, but you are not obligated to do so. If you do not wish to do
|
* file, but you are not obligated to do so. If you do not wish to do
|
||||||
so, delete this exception statement from your version.
|
* so, delete this exception statement from your version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
General Public License for more details.
|
* General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
02110-1301, USA
|
* 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@ -56,24 +56,24 @@
|
|||||||
static char *srvbase, *srvend, *srvcurrent;
|
static char *srvbase, *srvend, *srvcurrent;
|
||||||
|
|
||||||
void
|
void
|
||||||
conn_add_servers (void)
|
conn_add_servers(void)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int fd, len;
|
int fd, len;
|
||||||
|
|
||||||
fd = open(param.server, O_RDONLY, 0);
|
fd = open(param.servers, O_RDONLY, 0);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
panic("%s: can't open %s\n", prog_name, param.server);
|
panic("%s: can't open %s\n", prog_name, param.servers);
|
||||||
|
|
||||||
fstat(fd, &st);
|
fstat(fd, &st);
|
||||||
if (st.st_size == 0)
|
if (st.st_size == 0)
|
||||||
panic("%s: file %s is empty\n", prog_name, param.server);
|
panic("%s: file %s is empty\n", prog_name, param.servers);
|
||||||
|
|
||||||
srvbase = (char *)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
srvbase = (char *)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
if (srvbase == (char *)-1)
|
if (srvbase == (char *)-1)
|
||||||
panic("%s: can't mmap the file: %s\n", prog_name, strerror(errno));
|
panic("%s: can't mmap the file: %s\n", prog_name, strerror(errno));
|
||||||
|
|
||||||
close (fd);
|
close(fd);
|
||||||
|
|
||||||
srvend = srvbase + st.st_size;
|
srvend = srvbase + st.st_size;
|
||||||
for (srvcurrent = srvbase; srvcurrent < srvend; srvcurrent += len + 1) {
|
for (srvcurrent = srvbase; srvcurrent < srvend; srvcurrent += len + 1) {
|
||||||
@ -84,24 +84,34 @@ conn_add_servers (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
conn_init (Conn *conn)
|
conn_init(Conn *conn)
|
||||||
{
|
{
|
||||||
int len;
|
if (param.servers) {
|
||||||
|
int len = strlen(srvcurrent);
|
||||||
|
conn->hostname = srvcurrent;
|
||||||
|
conn->hostname_len = len;
|
||||||
|
conn->fqdname = conn->hostname;
|
||||||
|
conn->fqdname_len = conn->hostname_len;
|
||||||
|
|
||||||
len = strlen(srvcurrent);
|
srvcurrent += len + 1;
|
||||||
conn->hostname = srvcurrent;
|
if (srvcurrent >= srvend)
|
||||||
conn->hostname_len = len;
|
srvcurrent = srvbase;
|
||||||
|
} else if (param.server_name) {
|
||||||
srvcurrent += len + 1;
|
conn->hostname = param.server;
|
||||||
if (srvcurrent >= srvend)
|
conn->hostname_len = strlen(param.server);
|
||||||
srvcurrent = srvbase;
|
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) {
|
||||||
@ -112,7 +122,7 @@ conn_init (Conn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (param.ssl_cipher_list) {
|
if (param.ssl_cipher_list) {
|
||||||
/* set order of ciphers */
|
/* set order of ciphers */
|
||||||
int ssl_err = SSL_set_cipher_list(conn->ssl, param.ssl_cipher_list);
|
int ssl_err = SSL_set_cipher_list(conn->ssl, param.ssl_cipher_list);
|
||||||
|
|
||||||
if (DBG > 2)
|
if (DBG > 2)
|
||||||
@ -125,16 +135,16 @@ conn_init (Conn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
conn_deinit (Conn *conn)
|
conn_deinit(Conn *conn)
|
||||||
{
|
{
|
||||||
assert (conn->sd < 0 && conn->state != S_FREE);
|
assert(conn->sd < 0 && conn->state != S_FREE);
|
||||||
assert (!conn->sendq);
|
assert(!conn->sendq);
|
||||||
assert (!conn->recvq);
|
assert(!conn->recvq);
|
||||||
assert (!conn->watchdog);
|
assert(!conn->watchdog);
|
||||||
conn->state = S_FREE;
|
conn->state = S_FREE;
|
||||||
|
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
if (param.use_ssl)
|
if (param.use_ssl)
|
||||||
SSL_free (conn->ssl);
|
SSL_free(conn->ssl);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -963,8 +963,11 @@ core_init(void)
|
|||||||
printf("%s: maximum number of open descriptors = %ld\n",
|
printf("%s: maximum number of open descriptors = %ld\n",
|
||||||
prog_name, rlimit.rlim_max);
|
prog_name, rlimit.rlim_max);
|
||||||
|
|
||||||
if (param.server)
|
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);
|
||||||
|
@ -137,6 +137,8 @@ static struct option longopts[] = {
|
|||||||
{"runtime", required_argument, (int *) ¶m.runtime, 0},
|
{"runtime", required_argument, (int *) ¶m.runtime, 0},
|
||||||
{"send-buffer", required_argument, (int *) ¶m.send_buffer_size, 0},
|
{"send-buffer", required_argument, (int *) ¶m.send_buffer_size, 0},
|
||||||
{"server", required_argument, (int *) ¶m.server, 0},
|
{"server", required_argument, (int *) ¶m.server, 0},
|
||||||
|
{"server-name", required_argument, (int *) ¶m.server_name, 0},
|
||||||
|
{"servers", required_argument, (int *) ¶m.servers, 0},
|
||||||
{"uri", required_argument, (int *) ¶m.uri, 0},
|
{"uri", required_argument, (int *) ¶m.uri, 0},
|
||||||
{"session-cookies", no_argument, (int *) ¶m.session_cookies, 1},
|
{"session-cookies", no_argument, (int *) ¶m.session_cookies, 1},
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
@ -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<--server 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"
|
||||||
@ -637,6 +639,10 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} else if (flag == ¶m.server)
|
} else if (flag == ¶m.server)
|
||||||
param.server = optarg;
|
param.server = optarg;
|
||||||
|
else if (flag == ¶m.server_name)
|
||||||
|
param.server_name = optarg;
|
||||||
|
else if (flag == ¶m.servers)
|
||||||
|
param.servers = optarg;
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
else if (flag == ¶m.ssl_cipher_list)
|
else if (flag == ¶m.ssl_cipher_list)
|
||||||
param.ssl_cipher_list = optarg;
|
param.ssl_cipher_list = optarg;
|
||||||
@ -974,13 +980,16 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param.server == NULL) {
|
if (param.server != NULL && param.servers != NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: must specify --server\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];
|
||||||
@ -1133,6 +1142,10 @@ main(int argc, char **argv)
|
|||||||
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)
|
if (param.server)
|
||||||
printf(" --server=%s", param.server);
|
printf(" --server=%s", param.server);
|
||||||
|
if (param.server_name)
|
||||||
|
printf(" --server_name=%s", param.server_name);
|
||||||
|
if (param.servers)
|
||||||
|
printf(" --servers=%s", param.servers);
|
||||||
if (param.port)
|
if (param.port)
|
||||||
printf(" --port=%d", param.port);
|
printf(" --port=%d", param.port);
|
||||||
if (param.uri)
|
if (param.uri)
|
||||||
|
@ -91,7 +91,9 @@ Rate_Info;
|
|||||||
typedef struct Cmdline_Params
|
typedef struct Cmdline_Params
|
||||||
{
|
{
|
||||||
int http_version; /* (default) HTTP protocol version */
|
int http_version; /* (default) HTTP protocol version */
|
||||||
const char *server;
|
const char *server; /* (default) hostname */
|
||||||
|
const char *server_name; /* fully qualified server name */
|
||||||
|
const char *servers;
|
||||||
int port; /* (default) server port */
|
int port; /* (default) server port */
|
||||||
const char *uri; /* (default) uri */
|
const char *uri; /* (default) uri */
|
||||||
const char *myaddr;
|
const char *myaddr;
|
||||||
@ -154,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 */
|
||||||
|
Loading…
Reference in New Issue
Block a user