diff --git a/lib/quicly.c b/lib/quicly.c index 522bd6ee..be44bb4a 100644 --- a/lib/quicly.c +++ b/lib/quicly.c @@ -90,8 +90,10 @@ KHASH_MAP_INIT_INT64(quicly_stream_t, quicly_stream_t *) QUICLY_##label(_conn, __VA_ARGS__); \ QUICLY_TRACER(label, _conn, __VA_ARGS__); \ } while (0) +#define QUICLY_PROBE_ENABLED(label) (QUICLY_##label##_ENABLED()) #else #define QUICLY_PROBE(label, conn, ...) QUICLY_TRACER(label, conn, __VA_ARGS__) +#define QUICLY_PROBE_ENABLED(label) (0) #endif #define QUICLY_PROBE_HEXDUMP(s, l) \ ({ \ @@ -1938,7 +1940,7 @@ static int new_path(quicly_conn_t *conn, size_t path_index, struct sockaddr *rem conn->paths[path_index] = path; - if (QUICLY_NEW_PATH_ENABLED() || ptls_log.is_active) { + if (QUICLY_PROBE_ENABLED(NEW_PATH) || ptls_log.is_active) { char remote[sizeof(LONGEST_ADDRESS_STR)], local[sizeof(LONGEST_ADDRESS_STR)]; stringify_address(remote, &path->address.remote.sa); if (path->address.local.sa.sa_family != AF_UNSPEC) { @@ -1946,7 +1948,7 @@ static int new_path(quicly_conn_t *conn, size_t path_index, struct sockaddr *rem } else { local[0] = '\0'; } - QUICLY_NEW_PATH(conn, conn->stash.now, path_index, remote, local); + QUICLY_PROBE(NEW_PATH, conn, conn->stash.now, path_index, remote, local); QUICLY_LOG_CONN(new_path, conn, { PTLS_LOG_ELEMENT_UNSIGNED(path_index, path_index); PTLS_LOG_ELEMENT_SAFESTR(remote, remote); @@ -1981,14 +1983,14 @@ static int delete_path(quicly_conn_t *conn, size_t path_index, enum delete_path_ /* fetch and detach the path object to be freed */ if (mode == DELETE_PATH_MODE_PROMOTE) { assert(path_index != 0); - QUICLY_PROMOTE_PATH(conn, conn->stash.now, path_index); + QUICLY_PROBE(PROMOTE_PATH, conn, conn->stash.now, path_index); QUICLY_LOG_CONN(promote_path, conn, { PTLS_LOG_ELEMENT_UNSIGNED(path_index, path_index); }); path = conn->paths[0]; conn->paths[0] = conn->paths[path_index]; conn->paths[path_index] = NULL; conn->super.stats.num_paths.promoted += 1; } else { - QUICLY_DELETE_PATH(conn, conn->stash.now, path_index); + QUICLY_PROBE(DELETE_PATH, conn, conn->stash.now, path_index); QUICLY_LOG_CONN(delete_path, conn, { PTLS_LOG_ELEMENT_UNSIGNED(path_index, path_index); }); path = conn->paths[path_index]; conn->paths[path_index] = NULL; @@ -2097,14 +2099,12 @@ void quicly_free(quicly_conn_t *conn) QUICLY_PROBE(FREE, conn, conn->stash.now); QUICLY_LOG_CONN(free, conn, {}); -#if QUICLY_USE_DTRACE - if (QUICLY_CONN_STATS_ENABLED()) { + if (QUICLY_PROBE_ENABLED(CONN_STATS)) { quicly_stats_t stats; quicly_get_stats(conn, &stats); QUICLY_PROBE(CONN_STATS, conn, conn->stash.now, &stats, sizeof(stats)); // TODO: emit stats with QUICLY_LOG_CONN() } -#endif destroy_all_streams(conn, 0, 1); update_open_count(conn->super.ctx, -1); clear_datagram_frame_payloads(conn); @@ -5470,7 +5470,7 @@ int quicly_send(quicly_conn_t *conn, quicly_address_t *dest, quicly_address_t *s assert(success); } - if ((QUICLY_SEND_ENABLED() || ptls_log.is_active) && !ptls_skip_tracing(conn->crypto.tls)) { + if ((QUICLY_PROBE_ENABLED(SEND) || ptls_log.is_active) && !ptls_skip_tracing(conn->crypto.tls)) { const quicly_cid_t *dcid = get_dcid(conn, 0); QUICLY_PROBE(SEND, conn, conn->stash.now, conn->super.state, QUICLY_PROBE_HEXDUMP(dcid->cid, dcid->len)); QUICLY_LOG_CONN(send, conn, { @@ -7204,7 +7204,7 @@ int quicly_receive(quicly_conn_t *conn, struct sockaddr *dest_addr, struct socka assert(path_index != 0); conn->paths[path_index]->probe_only = 0; ++conn->super.stats.num_paths.migration_elicited; - QUICLY_ELICIT_PATH_MIGRATION(conn, conn->stash.now, path_index); + QUICLY_PROBE(ELICIT_PATH_MIGRATION, conn, conn->stash.now, path_index); QUICLY_LOG_CONN(elicit_path_migration, conn, { PTLS_LOG_ELEMENT_UNSIGNED(path_index, path_index); }); } if (conn->super.state < QUICLY_STATE_CLOSING && space != NULL) { @@ -7757,7 +7757,7 @@ const quicly_stream_callbacks_t quicly_stream_noop_callbacks = { void quicly__debug_printf(quicly_conn_t *conn, const char *function, int line, const char *fmt, ...) { - if (QUICLY_DEBUG_MESSAGE_ENABLED() || ptls_log.is_active) { + if (QUICLY_PROBE_ENABLED(DEBUG_MESSAGE) || ptls_log.is_active) { char buf[1024]; va_list args; @@ -7765,7 +7765,7 @@ void quicly__debug_printf(quicly_conn_t *conn, const char *function, int line, c vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); - QUICLY_DEBUG_MESSAGE(conn, function, line, buf); + QUICLY_PROBE(DEBUG_MESSAGE, conn, function, line, buf); QUICLY_LOG_CONN(debug_message, conn, { PTLS_LOG_ELEMENT_UNSAFESTR(function, function, strlen(function)); PTLS_LOG_ELEMENT_SIGNED(line, line);