1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

RTC: Refine log for error pithy print

This commit is contained in:
winlin 2020-07-27 12:44:29 +08:00
parent 5f7d1e2c5b
commit ca004fe33f
4 changed files with 12 additions and 6 deletions

View file

@ -506,8 +506,8 @@ srs_error_t SrsUdpMuxListener::cycle()
uint64_t nn_loop = 0;
srs_utime_t time_last = srs_get_system_time();
SrsErrorPithyPrint* epp = new SrsErrorPithyPrint();
SrsAutoFree(SrsErrorPithyPrint, epp);
SrsErrorPithyPrint* pp_pkt_handler_err = new SrsErrorPithyPrint();
SrsAutoFree(SrsErrorPithyPrint, pp_pkt_handler_err);
set_socket_buffer();
@ -542,8 +542,8 @@ srs_error_t SrsUdpMuxListener::cycle()
err = handler->on_udp_packet(&skt);
}
if (err != srs_success) {
if (epp->can_print(err)) {
srs_warn("handle udp pkt err: %s", srs_error_desc(err).c_str());
if (pp_pkt_handler_err->can_print(err)) {
srs_warn("handle udp pkt, count=%u, err: %s", pp_pkt_handler_err->nn_count, srs_error_desc(err).c_str());
}
srs_freep(err);
}

View file

@ -116,6 +116,7 @@ SrsStageInfo* SrsStageManager::fetch_or_create(int stage_id, bool* pnew)
SrsErrorPithyPrint::SrsErrorPithyPrint()
{
nn_count = 0;
}
SrsErrorPithyPrint::~SrsErrorPithyPrint()
@ -130,6 +131,8 @@ bool SrsErrorPithyPrint::can_print(srs_error_t err)
bool SrsErrorPithyPrint::can_print(int error_code)
{
nn_count++;
bool new_stage = false;
SrsStageInfo* stage = stages.fetch_or_create(error_code, &new_stage);

View file

@ -68,6 +68,9 @@ public:
// For example, we use it for error pithy print for each UDP packet processing.
class SrsErrorPithyPrint
{
public:
// The number of call of can_print().
uint32_t nn_count;
private:
SrsStageManager stages;
std::map<int, srs_utime_t> ticks;

View file

@ -1956,8 +1956,8 @@ void SrsRtcConnection::update_sendonly_socket(SrsUdpMuxSocket* skt)
if (prev_peer_id.empty()) {
srs_trace("RTC: session address init %s", peer_id.c_str());
} else if (pp_address_change->can_print(skt->get_peer_port())) {
srs_trace("RTC: session address changed, update %s -> %s, cached=%d, total=%u", prev_peer_id.c_str(),
peer_id.c_str(), (addr_cache? 1:0), peer_addresses_.size());
srs_trace("RTC: session address change %s -> %s, cached=%d, nn_change=%u, nn_address=%u", prev_peer_id.c_str(),
peer_id.c_str(), (addr_cache? 1:0), pp_address_change->nn_count, peer_addresses_.size());
}
// Update the transport.