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

for #320, support macro to disable the complex send algorithm and enable tcp no delay. 2.0.129

This commit is contained in:
winlin 2015-03-03 17:22:44 +08:00
parent f619f174e6
commit 34d6a2ece5
7 changed files with 120 additions and 20 deletions

View file

@ -27,6 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
using namespace std;
@ -624,6 +625,9 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
mw_enabled = true;
change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost));
// set the sock options.
play_set_sock_options();
while (true) {
// collect elapse for pithy print.
pprint->elapse();
@ -1089,7 +1093,7 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms)
socklen_t sock_buf_size = sizeof(int);
getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &onb_sbuf, &sock_buf_size);
#ifdef SRS_PERF_MW_SO_SNDBUF
#ifdef SRS_PERF_MW_SO_SNDBUF
// the bytes:
// 4KB=4096, 8KB=8192, 16KB=16384, 32KB=32768, 64KB=65536,
// 128KB=131072, 256KB=262144, 512KB=524288
@ -1123,6 +1127,29 @@ void SrsRtmpConn::change_mw_sleep(int sleep_ms)
mw_sleep = sleep_ms;
}
void SrsRtmpConn::play_set_sock_options()
{
int fd = st_netfd_fileno(stfd);
#ifdef SRS_PERF_TCP_NODELAY
if (true) {
socklen_t nb_v = sizeof(int);
int ov = 0;
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &ov, &nb_v);
int v = 1;
// set the socket send buffer when required larger buffer
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, nb_v) < 0) {
srs_warn("set sock TCP_NODELAY=%d failed.", v);
}
getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, &nb_v);
srs_trace("set TCP_NODELAY %d=>%d", ov, v);
}
#endif
}
int SrsRtmpConn::check_edge_token_traverse_auth()
{
int ret = ERROR_SUCCESS;