Skip to content

Commit

Permalink
fix compile error on platforms lacking dtrace support
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuho committed Sep 20, 2023
1 parent ed364ea commit f0c7a75
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/quicly.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
({ \
Expand Down Expand Up @@ -1938,15 +1940,15 @@ 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) {
stringify_address(local, &path->address.local.sa);
} 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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -7757,15 +7757,15 @@ 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;

va_start(args, fmt);
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);
Expand Down

0 comments on commit f0c7a75

Please sign in to comment.