1
0
mirror of https://github.com/moparisthebest/spdylay synced 2024-12-22 07:38:52 -05:00

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, ssl_acceptcb,
handler, handler,
LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE, LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE,
512, get_config()->backlog,
fd); fd);
evconnlistener_set_error_cb(evlistener, evlistener_errorcb); evconnlistener_set_error_cb(evlistener, evlistener_errorcb);
return evlistener; return evlistener;
@ -333,6 +333,9 @@ void fill_default_config()
mod_config()->syslog = false; mod_config()->syslog = false;
mod_config()->syslog_facility = LOG_DAEMON; mod_config()->syslog_facility = LOG_DAEMON;
mod_config()->use_syslog = false; mod_config()->use_syslog = false;
// Default accept() backlog
mod_config()->backlog = 256;
} }
} // namespace } // namespace
@ -424,6 +427,9 @@ void print_help(std::ostream& out)
<< " Set syslog facility.\n" << " Set syslog facility.\n"
<< " Default: " << " Default: "
<< str_syslog_facility(get_config()->syslog_facility) << "\n" << 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" << " -h, --help Print this help.\n"
<< std::endl; << std::endl;
} }
@ -460,6 +466,7 @@ int main(int argc, char **argv)
{"conf", required_argument, &flag, 12 }, {"conf", required_argument, &flag, 12 },
{"syslog", no_argument, &flag, 13 }, {"syslog", no_argument, &flag, 13 },
{"syslog-facility", required_argument, &flag, 14 }, {"syslog-facility", required_argument, &flag, 14 },
{"backlog", required_argument, &flag, 15 },
{"help", no_argument, 0, 'h' }, {"help", no_argument, 0, 'h' },
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
@ -560,6 +567,10 @@ int main(int argc, char **argv)
// --syslog-facility // --syslog-facility
cmdcfgs.push_back(std::make_pair(SHRPX_OPT_SYSLOG_FACILITY, optarg)); cmdcfgs.push_back(std::make_pair(SHRPX_OPT_SYSLOG_FACILITY, optarg));
break; break;
case 15:
// --backlog
cmdcfgs.push_back(std::make_pair(SHRPX_OPT_BACKLOG, optarg));
break;
default: default:
break; 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_USER[] = "user";
const char SHRPX_OPT_SYSLOG[] = "syslog"; const char SHRPX_OPT_SYSLOG[] = "syslog";
const char SHRPX_OPT_SYSLOG_FACILITY[] = "syslog-facility"; const char SHRPX_OPT_SYSLOG_FACILITY[] = "syslog-facility";
const char SHRPX_OPT_BACKLOG[] = "backlog";
Config::Config() Config::Config()
: verbose(false), : verbose(false),
@ -92,7 +93,8 @@ Config::Config()
conf_path(0), conf_path(0),
syslog(false), syslog(false),
syslog_facility(0), syslog_facility(0),
use_syslog(false) use_syslog(false),
backlog(0)
{} {}
namespace { namespace {
@ -238,6 +240,8 @@ int parse_config(const char *opt, const char *optarg)
return -1; return -1;
} }
mod_config()->syslog_facility = facility; 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")) { } else if(util::strieq(opt, "conf")) {
LOG(WARNING) << "conf is ignored"; LOG(WARNING) << "conf is ignored";
} else { } 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_USER[];
extern const char SHRPX_OPT_SYSLOG[]; extern const char SHRPX_OPT_SYSLOG[];
extern const char SHRPX_OPT_SYSLOG_FACILITY[]; extern const char SHRPX_OPT_SYSLOG_FACILITY[];
extern const char SHRPX_OPT_BACKLOG[];
union sockaddr_union { union sockaddr_union {
sockaddr sa; sockaddr sa;
@ -100,6 +101,7 @@ struct Config {
int syslog_facility; int syslog_facility;
// This member finally decides syslog is used or not // This member finally decides syslog is used or not
bool use_syslog; bool use_syslog;
int backlog;
Config(); Config();
}; };