mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182
This commit is contained in:
parent
267846a3fa
commit
9fb4640a8f
9 changed files with 44 additions and 12 deletions
|
@ -342,6 +342,7 @@ Remark:
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
|
||||||
|
* v2.0, 2015-08-12, enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182
|
||||||
* v2.0, 2015-08-11, for [#442](https://github.com/simple-rtmp-server/srs/issues/442) support kickoff connected client. 2.0.181
|
* v2.0, 2015-08-11, for [#442](https://github.com/simple-rtmp-server/srs/issues/442) support kickoff connected client. 2.0.181
|
||||||
* v2.0, 2015-07-21, for [#169](https://github.com/simple-rtmp-server/srs/issues/169) support default values for transcode. 2.0.180
|
* v2.0, 2015-07-21, for [#169](https://github.com/simple-rtmp-server/srs/issues/169) support default values for transcode. 2.0.180
|
||||||
* v2.0, 2015-07-21, fix [#435](https://github.com/simple-rtmp-server/srs/issues/435) add pageUrl for HTTP callback on_play.
|
* v2.0, 2015-07-21, fix [#435](https://github.com/simple-rtmp-server/srs/issues/435) add pageUrl for HTTP callback on_play.
|
||||||
|
|
|
@ -851,6 +851,10 @@ vhost min.delay.com {
|
||||||
# drop the old whole gop.
|
# drop the old whole gop.
|
||||||
# default: 30
|
# default: 30
|
||||||
queue_length 10;
|
queue_length 10;
|
||||||
|
# whether enable the TCP_NODELAY
|
||||||
|
# if on, set the nodelay of fd by setsockopt
|
||||||
|
# default: off
|
||||||
|
tcp_nodelay on;
|
||||||
}
|
}
|
||||||
|
|
||||||
# the vhost for antisuck.
|
# the vhost for antisuck.
|
||||||
|
|
|
@ -12,4 +12,5 @@ vhost __defaultVhost__ {
|
||||||
enabled off;
|
enabled off;
|
||||||
}
|
}
|
||||||
mw_latency 100;
|
mw_latency 100;
|
||||||
|
tcp_nodelay on;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1750,7 +1750,7 @@ int SrsConfig::check_config()
|
||||||
&& n != "time_jitter" && n != "mix_correct"
|
&& n != "time_jitter" && n != "mix_correct"
|
||||||
&& n != "atc" && n != "atc_auto"
|
&& n != "atc" && n != "atc_auto"
|
||||||
&& n != "debug_srs_upnode"
|
&& n != "debug_srs_upnode"
|
||||||
&& n != "mr" && n != "mw_latency" && n != "min_latency"
|
&& n != "mr" && n != "mw_latency" && n != "min_latency" && n != "tcp_nodelay"
|
||||||
&& n != "security" && n != "http_remux"
|
&& n != "security" && n != "http_remux"
|
||||||
&& n != "http" && n != "http_static"
|
&& n != "http" && n != "http_static"
|
||||||
&& n != "hds"
|
&& n != "hds"
|
||||||
|
@ -2489,6 +2489,23 @@ bool SrsConfig::get_realtime_enabled(string vhost)
|
||||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_tcp_nodelay(string vhost)
|
||||||
|
{
|
||||||
|
static bool DEFAULT = false;
|
||||||
|
|
||||||
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
if (!conf) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf = conf->get("tcp_nodelay");
|
||||||
|
if (!conf || conf->arg0().empty()) {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
||||||
|
}
|
||||||
|
|
||||||
int SrsConfig::get_global_chunk_size()
|
int SrsConfig::get_global_chunk_size()
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = root->get("chunk_size");
|
SrsConfDirective* conf = root->get("chunk_size");
|
||||||
|
|
|
@ -522,6 +522,10 @@ public:
|
||||||
*/
|
*/
|
||||||
// TODO: FIXME: add utest for min_latency.
|
// TODO: FIXME: add utest for min_latency.
|
||||||
virtual bool get_realtime_enabled(std::string vhost);
|
virtual bool get_realtime_enabled(std::string vhost);
|
||||||
|
/**
|
||||||
|
* whether enable tcp nodelay for all clients of vhost.
|
||||||
|
*/
|
||||||
|
virtual bool get_tcp_nodelay(std::string vhost);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* get the global chunk size.
|
* get the global chunk size.
|
||||||
|
|
|
@ -591,7 +591,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
|
||||||
change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost));
|
change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost));
|
||||||
|
|
||||||
// set the sock options.
|
// set the sock options.
|
||||||
play_set_sock_options();
|
set_sock_options();
|
||||||
|
|
||||||
while (!disposed) {
|
while (!disposed) {
|
||||||
// collect elapse for pithy print.
|
// collect elapse for pithy print.
|
||||||
|
@ -770,6 +770,9 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set the sock options.
|
||||||
|
set_sock_options();
|
||||||
|
|
||||||
int64_t nb_msgs = 0;
|
int64_t nb_msgs = 0;
|
||||||
while (!disposed) {
|
while (!disposed) {
|
||||||
pprint->elapse();
|
pprint->elapse();
|
||||||
|
@ -1093,10 +1096,10 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms)
|
||||||
mw_sleep = sleep_ms;
|
mw_sleep = sleep_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsRtmpConn::play_set_sock_options()
|
void SrsRtmpConn::set_sock_options()
|
||||||
{
|
{
|
||||||
|
if (_srs_config->get_tcp_nodelay(req->vhost)) {
|
||||||
#ifdef SRS_PERF_TCP_NODELAY
|
#ifdef SRS_PERF_TCP_NODELAY
|
||||||
if (true) {
|
|
||||||
int fd = st_netfd_fileno(stfd);
|
int fd = st_netfd_fileno(stfd);
|
||||||
|
|
||||||
socklen_t nb_v = sizeof(int);
|
socklen_t nb_v = sizeof(int);
|
||||||
|
@ -1112,9 +1115,11 @@ void SrsRtmpConn::play_set_sock_options()
|
||||||
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, &nb_v);
|
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, &nb_v);
|
||||||
|
|
||||||
srs_trace("set TCP_NODELAY %d=>%d", ov, v);
|
srs_trace("set TCP_NODELAY %d=>%d", ov, v);
|
||||||
}
|
#else
|
||||||
|
srs_warn("SRS_PERF_TCP_NODELAY is disabled but tcp_nodelay configed.");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int SrsRtmpConn::check_edge_token_traverse_auth()
|
int SrsRtmpConn::check_edge_token_traverse_auth()
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,7 +119,7 @@ private:
|
||||||
virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool vhost_is_edge);
|
virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool vhost_is_edge);
|
||||||
virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
|
virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg);
|
||||||
virtual void change_mw_sleep(int sleep_ms);
|
virtual void change_mw_sleep(int sleep_ms);
|
||||||
virtual void play_set_sock_options();
|
virtual void set_sock_options();
|
||||||
private:
|
private:
|
||||||
virtual int check_edge_token_traverse_auth();
|
virtual int check_edge_token_traverse_auth();
|
||||||
virtual int connect_server(int origin_index, st_netfd_t* pstsock);
|
virtual int connect_server(int origin_index, st_netfd_t* pstsock);
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 2
|
#define VERSION_MAJOR 2
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 181
|
#define VERSION_REVISION 182
|
||||||
|
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
|
|
|
@ -167,8 +167,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
* user maybe need send small tcp packet for some network.
|
* user maybe need send small tcp packet for some network.
|
||||||
* @see https://github.com/simple-rtmp-server/srs/issues/320
|
* @see https://github.com/simple-rtmp-server/srs/issues/320
|
||||||
*/
|
*/
|
||||||
//#define SRS_PERF_TCP_NODELAY
|
|
||||||
#undef SRS_PERF_TCP_NODELAY
|
#undef SRS_PERF_TCP_NODELAY
|
||||||
|
#define SRS_PERF_TCP_NODELAY
|
||||||
/**
|
/**
|
||||||
* set the socket send buffer,
|
* set the socket send buffer,
|
||||||
* to force the server to send smaller tcp packet.
|
* to force the server to send smaller tcp packet.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue