1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #307, enable REUSEPORT to increase UDP buffer

This commit is contained in:
winlin 2020-04-12 08:55:43 +08:00
parent a7f2bde8e2
commit 78aad11eeb
6 changed files with 54 additions and 10 deletions

View file

@ -3614,7 +3614,7 @@ srs_error_t SrsConfig::check_normal_config()
for (int i = 0; conf && i < (int)conf->directives.size(); i++) {
string n = conf->at(i)->name;
if (n != "enabled" && n != "listen" && n != "dir" && n != "candidate" && n != "ecdsa"
&& n != "sendmmsg" && n != "encrypt") {
&& n != "sendmmsg" && n != "encrypt" && n != "reuseport") {
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal rtc_server.%s", n.c_str());
}
}
@ -4745,6 +4745,33 @@ int SrsConfig::get_rtc_server_sendmmsg()
#endif
}
int SrsConfig::get_rtc_server_reuseport()
{
#if defined(SO_REUSEPORT)
static int DEFAULT = 4;
#else
static int DEFAULT = 1;
#endif
SrsConfDirective* conf = root->get("rtc_server");
if (!conf) {
return DEFAULT;
}
conf = conf->get("reuseport");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
int reuseport = ::atoi(conf->arg0().c_str());
#if !defined(SO_REUSEPORT)
srs_warn("REUSEPORT not supported, reset %d to %d", reuseport, DEFAULT);
reuseport = DEFAULT
#endif
return reuseport;
}
SrsConfDirective* SrsConfig::get_rtc(string vhost)
{
SrsConfDirective* conf = get_vhost(vhost);