mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
Merge branch '2.0release' into develop
This commit is contained in:
commit
9528243b81
5 changed files with 50 additions and 11 deletions
|
@ -768,6 +768,17 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
|
||||||
}
|
}
|
||||||
srs_trace("vhost %s reload smi success.", vhost.c_str());
|
srs_trace("vhost %s reload smi success.", vhost.c_str());
|
||||||
}
|
}
|
||||||
|
// tcp_nodelay, only one per vhost
|
||||||
|
if (!srs_directive_equals(new_vhost->get("tcp_nodelay"), old_vhost->get("tcp_nodelay"))) {
|
||||||
|
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||||
|
ISrsReloadHandler* subscribe = *it;
|
||||||
|
if ((ret = subscribe->on_reload_vhost_tcp_nodelay(vhost)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("vhost %s notify subscribes tcp_nodelay failed. ret=%d", vhost.c_str(), ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
srs_trace("vhost %s reload tcp_nodelay success.", vhost.c_str());
|
||||||
|
}
|
||||||
// publish_1stpkt_timeout, only one per vhost
|
// publish_1stpkt_timeout, only one per vhost
|
||||||
if (!srs_directive_equals(new_vhost->get("publish_1stpkt_timeout"), old_vhost->get("publish_1stpkt_timeout"))) {
|
if (!srs_directive_equals(new_vhost->get("publish_1stpkt_timeout"), old_vhost->get("publish_1stpkt_timeout"))) {
|
||||||
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
|
||||||
|
|
|
@ -175,6 +175,11 @@ int ISrsReloadHandler::on_reload_vhost_smi(string /*vhost*/)
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ISrsReloadHandler::on_reload_vhost_tcp_nodelay(string /*vhost*/)
|
||||||
|
{
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
int ISrsReloadHandler::on_reload_vhost_realtime(string /*vhost*/)
|
int ISrsReloadHandler::on_reload_vhost_realtime(string /*vhost*/)
|
||||||
{
|
{
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
virtual int on_reload_vhost_mr(std::string vhost);
|
virtual int on_reload_vhost_mr(std::string vhost);
|
||||||
virtual int on_reload_vhost_mw(std::string vhost);
|
virtual int on_reload_vhost_mw(std::string vhost);
|
||||||
virtual int on_reload_vhost_smi(std::string vhost);
|
virtual int on_reload_vhost_smi(std::string vhost);
|
||||||
|
virtual int on_reload_vhost_tcp_nodelay(std::string vhost);
|
||||||
virtual int on_reload_vhost_realtime(std::string vhost);
|
virtual int on_reload_vhost_realtime(std::string vhost);
|
||||||
virtual int on_reload_vhost_p1stpt(std::string vhost);
|
virtual int on_reload_vhost_p1stpt(std::string vhost);
|
||||||
virtual int on_reload_vhost_pnt(std::string vhost);
|
virtual int on_reload_vhost_pnt(std::string vhost);
|
||||||
|
|
|
@ -94,6 +94,7 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* svr, st_netfd_t c)
|
||||||
mw_enabled = false;
|
mw_enabled = false;
|
||||||
realtime = SRS_PERF_MIN_LATENCY_ENABLED;
|
realtime = SRS_PERF_MIN_LATENCY_ENABLED;
|
||||||
send_min_interval = 0;
|
send_min_interval = 0;
|
||||||
|
tcp_nodelay = false;
|
||||||
|
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
}
|
}
|
||||||
|
@ -265,6 +266,19 @@ int SrsRtmpConn::on_reload_vhost_smi(string vhost)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrsRtmpConn::on_reload_vhost_tcp_nodelay(string vhost)
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
if (req->vhost != vhost) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_sock_options();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int SrsRtmpConn::on_reload_vhost_realtime(string vhost)
|
int SrsRtmpConn::on_reload_vhost_realtime(string vhost)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
@ -651,8 +665,8 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
|
||||||
// set the sock options.
|
// set the sock options.
|
||||||
set_sock_options();
|
set_sock_options();
|
||||||
|
|
||||||
srs_trace("start play smi=%.2f, mw_sleep=%d, mw_enabled=%d, realtime=%d",
|
srs_trace("start play smi=%.2f, mw_sleep=%d, mw_enabled=%d, realtime=%d, tcp_nodelay=%d",
|
||||||
send_min_interval, mw_sleep, mw_enabled, realtime);
|
send_min_interval, mw_sleep, mw_enabled, realtime, tcp_nodelay);
|
||||||
|
|
||||||
while (!disposed) {
|
while (!disposed) {
|
||||||
// collect elapse for pithy print.
|
// collect elapse for pithy print.
|
||||||
|
@ -837,15 +851,18 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize the publish timeout.
|
||||||
|
publish_1stpkt_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost);
|
||||||
|
publish_normal_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost);
|
||||||
|
|
||||||
// set the sock options.
|
// set the sock options.
|
||||||
set_sock_options();
|
set_sock_options();
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
bool mr = _srs_config->get_mr_enabled(req->vhost);
|
bool mr = _srs_config->get_mr_enabled(req->vhost);
|
||||||
int mr_sleep = _srs_config->get_mr_sleep_ms(req->vhost);
|
int mr_sleep = _srs_config->get_mr_sleep_ms(req->vhost);
|
||||||
publish_1stpkt_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost);
|
srs_trace("start publish mr=%d/%d, p1stpt=%d, pnt=%d, tcp_nodelay=%d",
|
||||||
publish_normal_timeout = _srs_config->get_publish_1stpkt_timeout(req->vhost);
|
mr, mr_sleep, publish_1stpkt_timeout, publish_normal_timeout, tcp_nodelay);
|
||||||
srs_trace("start publish mr=%d/%d, p1stpt=%d, pnt=%d", mr, mr_sleep, publish_1stpkt_timeout, publish_normal_timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nb_msgs = 0;
|
int64_t nb_msgs = 0;
|
||||||
|
@ -1173,7 +1190,9 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms)
|
||||||
|
|
||||||
void SrsRtmpConn::set_sock_options()
|
void SrsRtmpConn::set_sock_options()
|
||||||
{
|
{
|
||||||
if (_srs_config->get_tcp_nodelay(req->vhost)) {
|
bool nvalue = _srs_config->get_tcp_nodelay(req->vhost);
|
||||||
|
if (nvalue != tcp_nodelay) {
|
||||||
|
tcp_nodelay = nvalue;
|
||||||
#ifdef SRS_PERF_TCP_NODELAY
|
#ifdef SRS_PERF_TCP_NODELAY
|
||||||
int fd = st_netfd_fileno(stfd);
|
int fd = st_netfd_fileno(stfd);
|
||||||
|
|
||||||
|
@ -1182,7 +1201,7 @@ void SrsRtmpConn::set_sock_options()
|
||||||
int ov = 0;
|
int ov = 0;
|
||||||
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &ov, &nb_v);
|
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &ov, &nb_v);
|
||||||
|
|
||||||
int v = 1;
|
int v = tcp_nodelay;
|
||||||
// set the socket send buffer when required larger buffer
|
// set the socket send buffer when required larger buffer
|
||||||
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, nb_v) < 0) {
|
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, nb_v) < 0) {
|
||||||
srs_warn("set sock TCP_NODELAY=%d failed.", v);
|
srs_warn("set sock TCP_NODELAY=%d failed.", v);
|
||||||
|
|
|
@ -91,6 +91,8 @@ private:
|
||||||
int publish_1stpkt_timeout;
|
int publish_1stpkt_timeout;
|
||||||
// publish normal packet timeout in ms
|
// publish normal packet timeout in ms
|
||||||
int publish_normal_timeout;
|
int publish_normal_timeout;
|
||||||
|
// whether enable the tcp_nodelay.
|
||||||
|
bool tcp_nodelay;
|
||||||
public:
|
public:
|
||||||
SrsRtmpConn(SrsServer* svr, st_netfd_t c);
|
SrsRtmpConn(SrsServer* svr, st_netfd_t c);
|
||||||
virtual ~SrsRtmpConn();
|
virtual ~SrsRtmpConn();
|
||||||
|
@ -103,6 +105,7 @@ public:
|
||||||
virtual int on_reload_vhost_removed(std::string vhost);
|
virtual int on_reload_vhost_removed(std::string vhost);
|
||||||
virtual int on_reload_vhost_mw(std::string vhost);
|
virtual int on_reload_vhost_mw(std::string vhost);
|
||||||
virtual int on_reload_vhost_smi(std::string vhost);
|
virtual int on_reload_vhost_smi(std::string vhost);
|
||||||
|
virtual int on_reload_vhost_tcp_nodelay(std::string vhost);
|
||||||
virtual int on_reload_vhost_realtime(std::string vhost);
|
virtual int on_reload_vhost_realtime(std::string vhost);
|
||||||
virtual int on_reload_vhost_p1stpt(std::string vhost);
|
virtual int on_reload_vhost_p1stpt(std::string vhost);
|
||||||
virtual int on_reload_vhost_pnt(std::string vhost);
|
virtual int on_reload_vhost_pnt(std::string vhost);
|
||||||
|
|
Loading…
Reference in a new issue