diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index eee324613..2ae221b14 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -431,11 +431,18 @@ void SrsUdpMuxListener::set_socket_buffer() srs_error_t SrsUdpMuxListener::cycle() { srs_error_t err = srs_success; + + SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_recv(); + SrsAutoFree(SrsPithyPrint, pprint); + + uint64_t nn_loop = 0; while (true) { if ((err = trd->pull()) != srs_success) { return srs_error_wrap(err, "udp listener"); - } + } + + nn_loop++; SrsUdpMuxSocket skt(lfd); @@ -452,8 +459,13 @@ srs_error_t SrsUdpMuxListener::cycle() // remux udp never return srs_warn("udp packet handler error:%s", srs_error_desc(err).c_str()); srs_error_reset(err); - continue; - } + } + + pprint->elapse(); + if (pprint->can_print()) { + srs_trace("-> RTC #%d RECV schedule %" PRId64, srs_netfd_fileno(lfd), nn_loop); + nn_loop = 0; + } if (SrsUdpPacketRecvCycleInterval > 0) { srs_usleep(SrsUdpPacketRecvCycleInterval); diff --git a/trunk/src/app/srs_app_pithy_print.cpp b/trunk/src/app/srs_app_pithy_print.cpp index 09ae09cf6..84c3c854d 100644 --- a/trunk/src/app/srs_app_pithy_print.cpp +++ b/trunk/src/app/srs_app_pithy_print.cpp @@ -114,6 +114,8 @@ SrsPithyPrint::SrsPithyPrint(int _stage_id) #define SRS_CONSTS_STAGE_RTC_PLAY 12 // for the rtc send #define SRS_CONSTS_STAGE_RTC_SEND 13 +// for the rtc recv +#define SRS_CONSTS_STAGE_RTC_RECV 14 SrsPithyPrint* SrsPithyPrint::create_rtmp_play() { @@ -180,6 +182,11 @@ SrsPithyPrint* SrsPithyPrint::create_rtc_send() return new SrsPithyPrint(SRS_CONSTS_STAGE_RTC_SEND); } +SrsPithyPrint* SrsPithyPrint::create_rtc_recv() +{ + return new SrsPithyPrint(SRS_CONSTS_STAGE_RTC_RECV); +} + SrsPithyPrint::~SrsPithyPrint() { leave_stage(); diff --git a/trunk/src/app/srs_app_pithy_print.hpp b/trunk/src/app/srs_app_pithy_print.hpp index 77993b047..4518b7a7c 100644 --- a/trunk/src/app/srs_app_pithy_print.hpp +++ b/trunk/src/app/srs_app_pithy_print.hpp @@ -89,6 +89,7 @@ public: static SrsPithyPrint* create_http_stream_cache(); static SrsPithyPrint* create_rtc_play(); static SrsPithyPrint* create_rtc_send(); + static SrsPithyPrint* create_rtc_recv(); virtual ~SrsPithyPrint(); private: // Enter the specified stage, return the client id. diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index bdaa197f0..20af21ed2 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1670,6 +1670,9 @@ srs_error_t SrsRtcServer::cycle() uint64_t nn_msgs = 0; uint64_t nn_msgs_last = 0; + uint64_t nn_msgs_max = 0; + uint64_t nn_loop = 0; + uint64_t nn_wait = 0; srs_utime_t time_last = srs_get_system_time(); SrsStatistic* stat = SrsStatistic::instance(); @@ -1681,9 +1684,12 @@ srs_error_t SrsRtcServer::cycle() return err; } + nn_loop++; + int pos = cache_pos; if (pos <= 0) { waiting_msgs = true; + nn_wait++; srs_cond_wait(cond); continue; } @@ -1693,11 +1699,13 @@ srs_error_t SrsRtcServer::cycle() cache_pos = 0; mmsghdr* p = &hotspot[0]; - for (mmsghdr* end = p + pos; p < end; p += max_sendmmsg) { + mmsghdr* end = p + pos; + srs_netfd_t stfd = mmstfd; + for (; p < end; p += max_sendmmsg) { int vlen = (int)(end - p); vlen = srs_min(max_sendmmsg, vlen); - int r0 = srs_sendmmsg(mmstfd, p, (unsigned int)vlen, 0, SRS_UTIME_NO_TIMEOUT); + int r0 = srs_sendmmsg(stfd, p, (unsigned int)vlen, 0, SRS_UTIME_NO_TIMEOUT); if (r0 != vlen) { srs_warn("sendmsg %d msgs, %d done", vlen, r0); } @@ -1707,6 +1715,7 @@ srs_error_t SrsRtcServer::cycle() // Increase total messages. nn_msgs += pos; + nn_msgs_max = srs_max(pos, nn_msgs_max); pprint->elapse(); if (pprint->can_print()) { @@ -1719,9 +1728,11 @@ srs_error_t SrsRtcServer::cycle() pps_last = (int)((nn_msgs - nn_msgs_last) * SRS_UTIME_SECONDS / (srs_get_system_time() - time_last)); } } - srs_trace("-> RTC SEND %d by sendmmsg %d, total %" PRId64 ", pps %d/%d, sessions %d/%d", - pos, max_sendmmsg, nn_msgs, pps_average, pps_last, (int)map_username_session.size(), (int)map_id_session.size()); + + srs_trace("-> RTC #%d SEND %d by sendmmsg %d, pps %d/%d, sessions %d, schedule %" PRId64 "/%" PRId64 "/%"PRId64, + srs_netfd_fileno(stfd), pos, max_sendmmsg, pps_average, pps_last, (int)map_username_session.size(), nn_loop, nn_wait, nn_msgs_max); nn_msgs_last = nn_msgs; time_last = srs_get_system_time(); + nn_loop = nn_wait = nn_msgs_max = 0; } }