Skip to content

Commit

Permalink
prepare next advisory tick debug only when debug is enabled (#472)
Browse files Browse the repository at this point in the history
Co-authored-by: hadif <[email protected]>
  • Loading branch information
2 people authored and gwanglst committed Aug 27, 2023
1 parent 9db6bf3 commit 5f55027
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/liblsquic/lsquic_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -3214,13 +3214,16 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
&& lsquic_mh_count(&engine->conns_out))
{
#if LSQUIC_DEBUG_NEXT_ADV_TICK
if (LSQ_LOG_ENABLED(L))
{
conn = lsquic_mh_peek(&engine->conns_out);
engine->last_logged_conn = 0;
LSQ_LOGC(L, "next advisory tick is now: went past deadline last time "
"and have %u outgoing connection%.*s (%"CID_FMT" first)",
lsquic_mh_count(&engine->conns_out),
lsquic_mh_count(&engine->conns_out) != 1, "s",
CID_BITS(lsquic_conn_log_cid(conn)));
}
#endif
#if LSQUIC_CONN_STATS
conn = lsquic_mh_peek(&engine->conns_out);
Expand All @@ -3234,8 +3237,11 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
&& engine->pr_queue && lsquic_prq_have_pending(engine->pr_queue))
{
#if LSQUIC_DEBUG_NEXT_ADV_TICK
if (LSQ_LOG_ENABLED(L))
{
engine->last_logged_conn = 0;
LSQ_LOG(L, "next advisory tick is now: have pending PRQ elements");
}
#endif
*diff = 0;
return 1;
Expand All @@ -3244,13 +3250,16 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
if (lsquic_mh_count(&engine->conns_tickable))
{
#if LSQUIC_DEBUG_NEXT_ADV_TICK
if (LSQ_LOG_ENABLED(L))
{
conn = lsquic_mh_peek(&engine->conns_tickable);
engine->last_logged_conn = 0;
LSQ_LOGC(L, "next advisory tick is now: have %u tickable "
"connection%.*s (%"CID_FMT" first)",
lsquic_mh_count(&engine->conns_tickable),
lsquic_mh_count(&engine->conns_tickable) != 1, "s",
CID_BITS(lsquic_conn_log_cid(conn)));
}
#endif
#if LSQUIC_CONN_STATS
conn = lsquic_mh_peek(&engine->conns_tickable);
Expand Down Expand Up @@ -3286,28 +3295,31 @@ lsquic_engine_earliest_adv_tick (lsquic_engine_t *engine, int *diff)
now = lsquic_time_now();
*diff = (int) ((int64_t) next_time - (int64_t) now);
#if LSQUIC_DEBUG_NEXT_ADV_TICK
if (next_attq)
if (LSQ_LOG_ENABLED(L))
{
/* Deduplicate consecutive log messages about the same reason for the
* same connection.
* If diff is always zero or diff reset to a higher value, event is
* still logged.
*/
if (!((unsigned) next_attq->ae_why == engine->last_logged_ae_why
&& (uintptr_t) next_attq->ae_conn
== engine->last_logged_conn
&& *diff < engine->last_tick_diff))
if (next_attq)
{
engine->last_logged_conn = (uintptr_t) next_attq->ae_conn;
engine->last_logged_ae_why = (unsigned) next_attq->ae_why;
engine->last_tick_diff = *diff;
LSQ_LOGC(L, "next advisory tick is %d usec away: conn %"CID_FMT
": %s", *diff, CID_BITS(lsquic_conn_log_cid(next_attq->ae_conn)),
lsquic_attq_why2str(next_attq->ae_why));
/* Deduplicate consecutive log messages about the same reason for the
* same connection.
* If diff is always zero or diff reset to a higher value, event is
* still logged.
*/
if (!((unsigned) next_attq->ae_why == engine->last_logged_ae_why
&& (uintptr_t) next_attq->ae_conn
== engine->last_logged_conn
&& *diff < engine->last_tick_diff))
{
engine->last_logged_conn = (uintptr_t) next_attq->ae_conn;
engine->last_logged_ae_why = (unsigned) next_attq->ae_why;
engine->last_tick_diff = *diff;
LSQ_LOGC(L, "next advisory tick is %d usec away: conn %"CID_FMT
": %s", *diff, CID_BITS(lsquic_conn_log_cid(next_attq->ae_conn)),
lsquic_attq_why2str(next_attq->ae_why));
}
}
else
LSQ_LOG(L, "next advisory tick is %d usec away: resume sending", *diff);
}
else
LSQ_LOG(L, "next advisory tick is %d usec away: resume sending", *diff);
#endif

#if LSQUIC_CONN_STATS
Expand Down

0 comments on commit 5f55027

Please sign in to comment.