shrpx: Added --backlog option

This commit is contained in:
Tatsuhiro Tsujikawa 2012-08-02 01:28:59 +09:00
parent 0c10528ca3
commit 4623413a99
3 changed files with 19 additions and 2 deletions

View File

@ -196,7 +196,7 @@ evconnlistener* create_evlistener(ListenHandler *handler, int family)
ssl_acceptcb,
handler,
LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE,
512,
get_config()->backlog,
fd);
evconnlistener_set_error_cb(evlistener, evlistener_errorcb);
return evlistener;
@ -333,6 +333,9 @@ void fill_default_config()
mod_config()->syslog = false;
mod_config()->syslog_facility = LOG_DAEMON;
mod_config()->use_syslog = false;
// Default accept() backlog
mod_config()->backlog = 256;
}
} // namespace
@ -424,6 +427,9 @@ void print_help(std::ostream& out)
<< " Set syslog facility.\n"
<< " Default: "
<< str_syslog_facility(get_config()->syslog_facility) << "\n"
<< " --backlog=<NUM> Set listen backlog size.\n"
<< " Default: "
<< get_config()->backlog << "\n"
<< " -h, --help Print this help.\n"
<< std::endl;
}
@ -460,6 +466,7 @@ int main(int argc, char **argv)
{"conf", required_argument, &flag, 12 },
{"syslog", no_argument, &flag, 13 },
{"syslog-facility", required_argument, &flag, 14 },
{"backlog", required_argument, &flag, 15 },
{"help", no_argument, 0, 'h' },
{0, 0, 0, 0 }
};
@ -560,6 +567,10 @@ int main(int argc, char **argv)
// --syslog-facility
cmdcfgs.push_back(std::make_pair(SHRPX_OPT_SYSLOG_FACILITY, optarg));
break;
case 15:
// --backlog
cmdcfgs.push_back(std::make_pair(SHRPX_OPT_BACKLOG, optarg));
break;
default:
break;
}

View File

@ -66,6 +66,7 @@ const char SHRPX_OPT_PID_FILE[] = "pid-file";
const char SHRPX_OPT_USER[] = "user";
const char SHRPX_OPT_SYSLOG[] = "syslog";
const char SHRPX_OPT_SYSLOG_FACILITY[] = "syslog-facility";
const char SHRPX_OPT_BACKLOG[] = "backlog";
Config::Config()
: verbose(false),
@ -92,7 +93,8 @@ Config::Config()
conf_path(0),
syslog(false),
syslog_facility(0),
use_syslog(false)
use_syslog(false),
backlog(0)
{}
namespace {
@ -238,6 +240,8 @@ int parse_config(const char *opt, const char *optarg)
return -1;
}
mod_config()->syslog_facility = facility;
} else if(util::strieq(opt, SHRPX_OPT_BACKLOG)) {
mod_config()->backlog = strtol(optarg, 0, 10);
} else if(util::strieq(opt, "conf")) {
LOG(WARNING) << "conf is ignored";
} else {

View File

@ -58,6 +58,7 @@ extern const char SHRPX_OPT_PID_FILE[];
extern const char SHRPX_OPT_USER[];
extern const char SHRPX_OPT_SYSLOG[];
extern const char SHRPX_OPT_SYSLOG_FACILITY[];
extern const char SHRPX_OPT_BACKLOG[];
union sockaddr_union {
sockaddr sa;
@ -100,6 +101,7 @@ struct Config {
int syslog_facility;
// This member finally decides syslog is used or not
bool use_syslog;
int backlog;
Config();
};