Merge branch 'nshoemaker-r_n'

This commit is contained in:
Tatsuhiro Tsujikawa 2015-08-14 00:04:21 +09:00
commit 4839d6d513
1 changed files with 10 additions and 1 deletions

View File

@ -1115,6 +1115,7 @@ int main(int argc, char **argv) {
OPENSSL_config(nullptr); OPENSSL_config(nullptr);
std::string datafile; std::string datafile;
bool nreqs_set_manually = false;
while (1) { while (1) {
static int flag = 0; static int flag = 0;
static option long_options[] = { static option long_options[] = {
@ -1144,6 +1145,7 @@ int main(int argc, char **argv) {
switch (c) { switch (c) {
case 'n': case 'n':
config.nreqs = strtoul(optarg, nullptr, 10); config.nreqs = strtoul(optarg, nullptr, 10);
nreqs_set_manually = true;
break; break;
case 'c': case 'c':
config.nclients = strtoul(optarg, nullptr, 10); config.nclients = strtoul(optarg, nullptr, 10);
@ -1322,7 +1324,7 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (config.rate > config.nreqs) { if (nreqs_set_manually && config.rate > config.nreqs) {
std::cerr << "-r, -n: the connection rate must be smaller than or equal " std::cerr << "-r, -n: the connection rate must be smaller than or equal "
"to the number of requests." << std::endl; "to the number of requests." << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -1335,6 +1337,13 @@ int main(int argc, char **argv) {
<< "to the number of threads." << std::endl; << "to the number of threads." << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (config.nconns == 0 && !nreqs_set_manually) {
std::cerr
<< "-r: the rate option must be used with either the -n option "
"or the -C option." << std::endl;
exit(EXIT_FAILURE);
}
} }
if (!datafile.empty()) { if (!datafile.empty()) {