Use U64_FORMAT/U64_PRINTF_ARG rather than %lu for channel_t

This commit is contained in:
Andrea Shepard 2012-10-08 19:48:06 -07:00
parent 71ba517e0c
commit e709fe320a
5 changed files with 177 additions and 148 deletions

View file

@ -241,14 +241,15 @@ channel_register(channel_t *chan)
if (chan->is_listener) { if (chan->is_listener) {
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Registering listener channel %p (ID %lu) in state %s (%d)", "Registering listener channel %p (ID " U64_FORMAT ") "
chan, chan->global_identifier, "in state %s (%d)",
chan, U64_PRINTF_ARG(chan->global_identifier),
channel_state_to_string(chan->state), chan->state); channel_state_to_string(chan->state), chan->state);
} else { } else {
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Registering cell channel %p (ID %lu) in state %s (%d) " "Registering cell channel %p (ID " U64_FORMAT ") "
"with digest %s", "in state %s (%d) with digest %s",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
channel_state_to_string(chan->state), chan->state, channel_state_to_string(chan->state), chan->state,
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
} }
@ -282,9 +283,9 @@ channel_register(channel_t *chan)
channel_add_to_digest_map(chan); channel_add_to_digest_map(chan);
} else { } else {
log_info(LD_CHANNEL, log_info(LD_CHANNEL,
"Channel %p (global ID %lu) in state %s (%d) registered " "Channel %p (global ID " U64_FORMAT ") "
"with no identity digest", "in state %s (%d) registered with no identity digest",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
channel_state_to_string(chan->state), chan->state); channel_state_to_string(chan->state), chan->state);
} }
} }
@ -398,9 +399,9 @@ channel_add_to_digest_map(channel_t *chan)
} }
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Added channel %p (%lu) to identity map in state %s (%d) " "Added channel %p (global ID " U64_FORMAT ") "
"with digest %s", "to identity map in state %s (%d) with digest %s",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
channel_state_to_string(chan->state), chan->state, channel_state_to_string(chan->state), chan->state,
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
} }
@ -432,9 +433,10 @@ channel_remove_from_digest_map(channel_t *chan)
* case is similar to digestmap_get() failing below. * case is similar to digestmap_get() failing below.
*/ */
log_warn(LD_BUG, log_warn(LD_BUG,
"Trying to remove channel %p (%lu) with digest %s from " "Trying to remove channel %p (global ID " U64_FORMAT ") "
"identity map, but didn't have any identity map", "with digest %s from identity map, but didn't have any identity "
chan, chan->global_identifier, "map",
chan, U64_PRINTF_ARG(chan->global_identifier),
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
/* Clear out its next/prev pointers */ /* Clear out its next/prev pointers */
if (chan->u.cell_chan.next_with_same_id) { if (chan->u.cell_chan.next_with_same_id) {
@ -496,18 +498,18 @@ channel_remove_from_digest_map(channel_t *chan)
chan->u.cell_chan.prev_with_same_id = NULL; chan->u.cell_chan.prev_with_same_id = NULL;
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Removed channel %p (%lu) from identity map in state %s (%d) " "Removed channel %p (global ID " U64_FORMAT ") from "
"with digest %s", "identity map in state %s (%d) with digest %s",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
channel_state_to_string(chan->state), chan->state, channel_state_to_string(chan->state), chan->state,
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
} else { } else {
/* This is not good */ /* This is not good */
log_warn(LD_BUG, log_warn(LD_BUG,
"Trying to remove channel %p (%lu) with digest %s from " "Trying to remove channel %p (global ID " U64_FORMAT ") "
"identity map, but couldn't find it in the list for that " "with digest %s from identity map, but couldn't find it in "
"digest", "the list for that digest",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
/* Unlink it and hope for the best */ /* Unlink it and hope for the best */
if (chan->u.cell_chan.next_with_same_id) { if (chan->u.cell_chan.next_with_same_id) {
@ -526,9 +528,10 @@ channel_remove_from_digest_map(channel_t *chan)
} else { } else {
/* Shouldn't happen */ /* Shouldn't happen */
log_warn(LD_BUG, log_warn(LD_BUG,
"Trying to remove channel %p (%lu) with digest %s from " "Trying to remove channel %p (global ID " U64_FORMAT ") with "
"identity map, but couldn't find any with that digest", "digest %s from identity map, but couldn't find any with "
chan, chan->global_identifier, "that digest",
chan, U64_PRINTF_ARG(chan->global_identifier),
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
/* Clear out its next/prev pointers */ /* Clear out its next/prev pointers */
if (chan->u.cell_chan.next_with_same_id) { if (chan->u.cell_chan.next_with_same_id) {
@ -1256,8 +1259,8 @@ channel_clear_identity_digest(channel_t *chan)
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Clearing remote endpoint digest on channel %p with " "Clearing remote endpoint digest on channel %p with "
"global ID %lu", "global ID " U64_FORMAT,
chan, chan->global_identifier); chan, U64_PRINTF_ARG(chan->global_identifier));
state_not_in_map = state_not_in_map =
(chan->state == CHANNEL_STATE_LISTENING || (chan->state == CHANNEL_STATE_LISTENING ||
@ -1295,8 +1298,8 @@ channel_set_identity_digest(channel_t *chan,
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Setting remote endpoint digest on channel %p with " "Setting remote endpoint digest on channel %p with "
"global ID %lu to digest %s", "global ID " U64_FORMAT " to digest %s",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
identity_digest ? identity_digest ?
hex_str(identity_digest, DIGEST_LEN) : "(null)"); hex_str(identity_digest, DIGEST_LEN) : "(null)");
@ -1354,8 +1357,8 @@ channel_clear_remote_end(channel_t *chan)
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Clearing remote endpoint identity on channel %p with " "Clearing remote endpoint identity on channel %p with "
"global ID %lu", "global ID " U64_FORMAT,
chan, chan->global_identifier); chan, U64_PRINTF_ARG(chan->global_identifier));
state_not_in_map = state_not_in_map =
(chan->state == CHANNEL_STATE_LISTENING || (chan->state == CHANNEL_STATE_LISTENING ||
@ -1396,8 +1399,8 @@ channel_set_remote_end(channel_t *chan,
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Setting remote endpoint identity on channel %p with " "Setting remote endpoint identity on channel %p with "
"global ID %lu to nickname %s, digest %s", "global ID " U64_FORMAT " to nickname %s, digest %s",
chan, chan->global_identifier, chan, U64_PRINTF_ARG(chan->global_identifier),
nickname ? nickname : "(null)", nickname ? nickname : "(null)",
identity_digest ? identity_digest ?
hex_str(identity_digest, DIGEST_LEN) : "(null)"); hex_str(identity_digest, DIGEST_LEN) : "(null)");
@ -1469,8 +1472,9 @@ channel_write_cell(channel_t *chan, cell_t *cell)
chan->state == CHANNEL_STATE_MAINT); chan->state == CHANNEL_STATE_MAINT);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Writing cell_t %p to channel %p with global ID %lu", "Writing cell_t %p to channel %p with global ID "
cell, chan, chan->global_identifier); U64_FORMAT,
cell, chan, U64_PRINTF_ARG(chan->global_identifier));
/* Increment the timestamp unless it's padding */ /* Increment the timestamp unless it's padding */
if (!(cell->command == CELL_PADDING || if (!(cell->command == CELL_PADDING ||
@ -1532,8 +1536,10 @@ channel_write_packed_cell(channel_t *chan, packed_cell_t *packed_cell)
chan->state == CHANNEL_STATE_MAINT); chan->state == CHANNEL_STATE_MAINT);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Writing packed_cell_t %p to channel %p with global ID %lu", "Writing packed_cell_t %p to channel %p with global ID "
packed_cell, chan, chan->global_identifier); U64_FORMAT,
packed_cell, chan,
U64_PRINTF_ARG(chan->global_identifier));
/* Increment the timestamp */ /* Increment the timestamp */
chan->u.cell_chan.timestamp_last_added_nonpadding = approx_time(); chan->u.cell_chan.timestamp_last_added_nonpadding = approx_time();
@ -1594,8 +1600,10 @@ channel_write_var_cell(channel_t *chan, var_cell_t *var_cell)
chan->state == CHANNEL_STATE_MAINT); chan->state == CHANNEL_STATE_MAINT);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Writing var_cell_t %p to channel %p with global ID %lu", "Writing var_cell_t %p to channel %p with global ID "
var_cell, chan, chan->global_identifier); U64_FORMAT,
var_cell, chan,
U64_PRINTF_ARG(chan->global_identifier));
/* Increment the timestamp unless it's padding */ /* Increment the timestamp unless it's padding */
if (!(var_cell->command == CELL_PADDING || if (!(var_cell->command == CELL_PADDING ||
@ -2064,8 +2072,8 @@ channel_process_incoming(channel_t *listener)
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Processing queue of incoming connections for listening " "Processing queue of incoming connections for listening "
"channel %p (global ID %lu)", "channel %p (global ID " U64_FORMAT ")",
listener, listener->global_identifier); listener, U64_PRINTF_ARG(listener->global_identifier));
if (!(listener->u.listener.incoming_list)) return; if (!(listener->u.listener.incoming_list)) return;
@ -2075,9 +2083,12 @@ channel_process_incoming(channel_t *listener)
tor_assert(!(chan->is_listener)); tor_assert(!(chan->is_listener));
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Handling incoming connection %p (%lu) for listener %p (%lu)", "Handling incoming connection %p (" U64_FORMAT ") "
chan, chan->global_identifier, "for listener %p (" U64_FORMAT ")",
listener, listener->global_identifier); chan,
U64_PRINTF_ARG(chan->global_identifier),
listener,
U64_PRINTF_ARG(listener->global_identifier));
/* Make sure this is set correctly */ /* Make sure this is set correctly */
channel_mark_incoming(chan); channel_mark_incoming(chan);
listener->u.listener.listener(listener, chan); listener->u.listener.listener(listener, chan);
@ -2524,8 +2535,9 @@ channel_free_all(void)
/* Deregister and free it */ /* Deregister and free it */
tor_assert(tmp); tor_assert(tmp);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Cleaning up finished channel %p (ID %lu) in state %s (%d)", "Cleaning up finished channel %p (ID " U64_FORMAT ") "
tmp, tmp->global_identifier, "in state %s (%d)",
tmp, U64_PRINTF_ARG(tmp->global_identifier),
channel_state_to_string(tmp->state), tmp->state); channel_state_to_string(tmp->state), tmp->state);
channel_unregister(tmp); channel_unregister(tmp);
channel_free(tmp); channel_free(tmp);
@ -2545,8 +2557,9 @@ channel_free_all(void)
/* Close, deregister and free it */ /* Close, deregister and free it */
tor_assert(tmp); tor_assert(tmp);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Cleaning up listening channel %p (ID %lu) in state %s (%d)", "Cleaning up listening channel %p (ID " U64_FORMAT ") "
tmp, tmp->global_identifier, "in state %s (%d)",
tmp, U64_PRINTF_ARG(tmp->global_identifier),
channel_state_to_string(tmp->state), tmp->state); channel_state_to_string(tmp->state), tmp->state);
/* /*
* We have to unregister first so we don't put it in finished_channels * We have to unregister first so we don't put it in finished_channels
@ -2570,8 +2583,9 @@ channel_free_all(void)
/* Close, deregister and free it */ /* Close, deregister and free it */
tor_assert(tmp); tor_assert(tmp);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Cleaning up active channel %p (ID %lu) in state %s (%d)", "Cleaning up active channel %p (ID " U64_FORMAT ") "
tmp, tmp->global_identifier, "in state %s (%d)",
tmp, U64_PRINTF_ARG(tmp->global_identifier),
channel_state_to_string(tmp->state), tmp->state); channel_state_to_string(tmp->state), tmp->state);
/* /*
* We have to unregister first so we don't put it in finished_channels * We have to unregister first so we don't put it in finished_channels
@ -2595,8 +2609,9 @@ channel_free_all(void)
/* Close, deregister and free it */ /* Close, deregister and free it */
tor_assert(tmp); tor_assert(tmp);
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Cleaning up leftover channel %p (ID %lu) in state %s (%d)", "Cleaning up leftover channel %p (ID " U64_FORMAT ") "
tmp, tmp->global_identifier, "in state %s (%d)",
tmp, U64_PRINTF_ARG(tmp->global_identifier),
channel_state_to_string(tmp->state), tmp->state); channel_state_to_string(tmp->state), tmp->state);
channel_unregister(tmp); channel_unregister(tmp);
if (!(tmp->state == CHANNEL_STATE_CLOSING || if (!(tmp->state == CHANNEL_STATE_CLOSING ||
@ -2875,27 +2890,32 @@ channel_dump_statistics(channel_t *chan, int severity)
age = (double)(now - chan->timestamp_created); age = (double)(now - chan->timestamp_created);
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
"Channel %lu (at %p) with transport %s is in state %s (%d) and %s", "Channel " U64_FORMAT " (at %p) with transport %s is in state "
chan->global_identifier, chan, "%s (%d) and %s",
U64_PRINTF_ARG(chan->global_identifier), chan,
channel_describe_transport(chan), channel_describe_transport(chan),
channel_state_to_string(chan->state), chan->state, channel_state_to_string(chan->state), chan->state,
chan->is_listener ? chan->is_listener ?
"listens for incoming connections" : "listens for incoming connections" :
"transports cells"); "transports cells");
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Channel %lu was created at %lu (%lu seconds ago) and last active " " * Channel " U64_FORMAT " was created at " U64_FORMAT
"at %lu (%lu seconds ago)", " (" U64_FORMAT " seconds ago) "
chan->global_identifier, "and last active at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
chan->timestamp_created, now - chan->timestamp_created, U64_PRINTF_ARG(chan->global_identifier),
chan->timestamp_active, now - chan->timestamp_active); U64_PRINTF_ARG(chan->timestamp_created),
U64_PRINTF_ARG(now - chan->timestamp_created),
U64_PRINTF_ARG(chan->timestamp_active),
U64_PRINTF_ARG(now - chan->timestamp_active));
if (chan->is_listener) { if (chan->is_listener) {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Listener channel %lu last accepted an incoming channel at %lu " " * Listener channel " U64_FORMAT " last accepted an incoming "
"(%lu seconds ago) and has accepted %lu channels in total", "channel at " U64_FORMAT " (" U64_FORMAT " seconds ago) "
chan->global_identifier, "and has accepted " U64_FORMAT " channels in total",
chan->u.listener.timestamp_accepted, U64_PRINTF_ARG(chan->global_identifier),
now - chan->u.listener.timestamp_accepted, U64_PRINTF_ARG(chan->u.listener.timestamp_accepted),
chan->u.listener.n_accepted); U64_PRINTF_ARG(now - chan->u.listener.timestamp_accepted),
U64_PRINTF_ARG(chan->u.listener.n_accepted));
/* /*
* If it's sensible to do so, get the rate of incoming channels on this * If it's sensible to do so, get the rate of incoming channels on this
@ -2907,15 +2927,15 @@ channel_dump_statistics(channel_t *chan, int severity)
avg = (double)(chan->u.listener.n_accepted) / age; avg = (double)(chan->u.listener.n_accepted) / age;
if (avg >= 1.0) { if (avg >= 1.0) {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Listener channel %lu has averaged %f incoming channels per " " * Listener channel " U64_FORMAT " has averaged %f incoming "
"second", "channels per second",
chan->global_identifier, avg); U64_PRINTF_ARG(chan->global_identifier), avg);
} else if (avg >= 0.0) { } else if (avg >= 0.0) {
interval = 1.0 / avg; interval = 1.0 / avg;
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Listener channel %lu has averaged %f seconds between " " * Listener channel " U64_FORMAT " has averaged %f seconds "
"incoming channels", "between incoming channels",
chan->global_identifier, interval); U64_PRINTF_ARG(chan->global_identifier), interval);
} }
} }
} else { } else {
@ -2923,30 +2943,30 @@ channel_dump_statistics(channel_t *chan, int severity)
if (!tor_digest_is_zero(chan->u.cell_chan.identity_digest)) { if (!tor_digest_is_zero(chan->u.cell_chan.identity_digest)) {
if (chan->u.cell_chan.nickname) { if (chan->u.cell_chan.nickname) {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu says it is connected to an OR " " * Cell-bearing channel " U64_FORMAT " says it is connected "
"with digest %s and nickname %s", "to an OR with digest %s and nickname %s",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN), hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN),
chan->u.cell_chan.nickname); chan->u.cell_chan.nickname);
} else { } else {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu says it is connected to an OR " " * Cell-bearing channel " U64_FORMAT " says it is connected "
"with digest %s and no known nickname", "to an OR with digest %s and no known nickname",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN)); hex_str(chan->u.cell_chan.identity_digest, DIGEST_LEN));
} }
} else { } else {
if (chan->u.cell_chan.nickname) { if (chan->u.cell_chan.nickname) {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu does not know the digest of the " " * Cell-bearing channel " U64_FORMAT " does not know the digest"
"OR it is connected to, but reports its nickname is %s", " of the OR it is connected to, but reports its nickname is %s",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
chan->u.cell_chan.nickname); chan->u.cell_chan.nickname);
} else { } else {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu does not know the digest or the " " * Cell-bearing channel " U64_FORMAT " does not know the digest"
"nickname of the OR it is connected to", " or the nickname of the OR it is connected to",
chan->global_identifier); U64_PRINTF_ARG(chan->global_identifier));
} }
} }
@ -2955,29 +2975,29 @@ channel_dump_statistics(channel_t *chan, int severity)
if (have_remote_addr) { if (have_remote_addr) {
remote_addr_str = tor_dup_addr(&remote_addr); remote_addr_str = tor_dup_addr(&remote_addr);
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu says its remote address is %s, " " * Cell-bearing channel " U64_FORMAT " says its remote address"
"and gives a canonical description of \"%s\" and an " " is %s, and gives a canonical description of \"%s\" and an "
"actual description of \"%s\"", "actual description of \"%s\"",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
remote_addr_str, remote_addr_str,
channel_get_canonical_remote_descr(chan), channel_get_canonical_remote_descr(chan),
channel_get_actual_remote_descr(chan)); channel_get_actual_remote_descr(chan));
tor_free(remote_addr_str); tor_free(remote_addr_str);
} else { } else {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu does not know its remote address, " " * Cell-bearing channel " U64_FORMAT " does not know its remote "
"but gives a canonical description of \"%s\" and an " "address, but gives a canonical description of \"%s\" and an "
"actual description of \"%s\"", "actual description of \"%s\"",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
channel_get_canonical_remote_descr(chan), channel_get_canonical_remote_descr(chan),
channel_get_actual_remote_descr(chan)); channel_get_actual_remote_descr(chan));
} }
/* Handle marks */ /* Handle marks */
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has these marks: %s %s %s " " * Cell-bearing channel " U64_FORMAT " has these marks: %s %s %s "
"%s %s %s", "%s %s %s",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
channel_is_bad_for_new_circs(chan) ? channel_is_bad_for_new_circs(chan) ?
"bad_for_new_circs" : "!bad_for_new_circs", "bad_for_new_circs" : "!bad_for_new_circs",
channel_is_canonical(chan) ? channel_is_canonical(chan) ?
@ -2994,9 +3014,9 @@ channel_dump_statistics(channel_t *chan, int severity)
/* Describe queues */ /* Describe queues */
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has %d queued incoming cells " " * Cell-bearing channel " U64_FORMAT " has %d queued incoming cells"
"and %d queued outgoing cells", " and %d queued outgoing cells",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
(chan->u.cell_chan.cell_queue != NULL) ? (chan->u.cell_chan.cell_queue != NULL) ?
smartlist_len(chan->u.cell_chan.cell_queue) : 0, smartlist_len(chan->u.cell_chan.cell_queue) : 0,
(chan->u.cell_chan.outgoing_queue != NULL) ? (chan->u.cell_chan.outgoing_queue != NULL) ?
@ -3004,9 +3024,9 @@ channel_dump_statistics(channel_t *chan, int severity)
/* Describe circuits */ /* Describe circuits */
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has %d active circuits out of %d" " * Cell-bearing channel " U64_FORMAT " has %d active circuits out of"
" in total", " %d in total",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
(chan->u.cell_chan.active_circuit_pqueue != NULL) ? (chan->u.cell_chan.active_circuit_pqueue != NULL) ?
smartlist_len(chan->u.cell_chan.active_circuit_pqueue) : 0, smartlist_len(chan->u.cell_chan.active_circuit_pqueue) : 0,
chan->u.cell_chan.n_circuits); chan->u.cell_chan.n_circuits);
@ -3014,67 +3034,67 @@ channel_dump_statistics(channel_t *chan, int severity)
/* Describe timestamps */ /* Describe timestamps */
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu was last used by a client at %lu " " * Cell-bearing channel " U64_FORMAT " was last used by a "
"(%lu seconds ago)", "client at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
chan->u.cell_chan.timestamp_client, U64_PRINTF_ARG(chan->u.cell_chan.timestamp_client),
now - chan->u.cell_chan.timestamp_client); U64_PRINTF_ARG(now - chan->u.cell_chan.timestamp_client));
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu was last drained at %lu " " * Cell-bearing channel " U64_FORMAT " was last drained at "
"(%lu seconds ago)", U64_FORMAT " (" U64_FORMAT " seconds ago)",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
chan->u.cell_chan.timestamp_drained, U64_PRINTF_ARG(chan->u.cell_chan.timestamp_drained),
now - chan->u.cell_chan.timestamp_drained); U64_PRINTF_ARG(now - chan->u.cell_chan.timestamp_drained));
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu last received a cell at %lu " " * Cell-bearing channel " U64_FORMAT " last received a cell "
"(%lu seconds ago)", "at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
chan->u.cell_chan.timestamp_recv, U64_PRINTF_ARG(chan->u.cell_chan.timestamp_recv),
now - chan->u.cell_chan.timestamp_recv); U64_PRINTF_ARG(now - chan->u.cell_chan.timestamp_recv));
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu last trasmitted a cell at %lu " " * Cell-bearing channel " U64_FORMAT " last trasmitted a cell "
"(%lu seconds ago)", "at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
chan->u.cell_chan.timestamp_xmit, U64_PRINTF_ARG(chan->u.cell_chan.timestamp_xmit),
now - chan->u.cell_chan.timestamp_xmit); U64_PRINTF_ARG(now - chan->u.cell_chan.timestamp_xmit));
/* Describe counters and rates */ /* Describe counters and rates */
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has received %lu cells and " " * Cell-bearing channel " U64_FORMAT " has received "
" transmitted %lu", U64_FORMAT " cells and transmitted " U64_FORMAT,
chan->global_identifier, U64_PRINTF_ARG(chan->global_identifier),
chan->u.cell_chan.n_cells_recved, U64_PRINTF_ARG(chan->u.cell_chan.n_cells_recved),
chan->u.cell_chan.n_cells_xmitted); U64_PRINTF_ARG(chan->u.cell_chan.n_cells_xmitted));
if (now > chan->timestamp_created && if (now > chan->timestamp_created &&
chan->timestamp_created > 0) { chan->timestamp_created > 0) {
if (chan->u.cell_chan.n_cells_recved > 0) { if (chan->u.cell_chan.n_cells_recved > 0) {
avg = (double)(chan->u.cell_chan.n_cells_recved) / age; avg = (double)(chan->u.cell_chan.n_cells_recved) / age;
if (avg >= 1.0) { if (avg >= 1.0) {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has averaged %f cells received " " * Cell-bearing channel " U64_FORMAT " has averaged %f "
"per second", "cells received per second",
chan->global_identifier, avg); U64_PRINTF_ARG(chan->global_identifier), avg);
} else if (avg >= 0.0) { } else if (avg >= 0.0) {
interval = 1.0 / avg; interval = 1.0 / avg;
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has averaged %f seconds between " " * Cell-bearing channel " U64_FORMAT " has averaged %f "
"received cells", "seconds between received cells",
chan->global_identifier, interval); U64_PRINTF_ARG(chan->global_identifier), interval);
} }
} }
if (chan->u.cell_chan.n_cells_xmitted > 0) { if (chan->u.cell_chan.n_cells_xmitted > 0) {
avg = (double)(chan->u.cell_chan.n_cells_xmitted) / age; avg = (double)(chan->u.cell_chan.n_cells_xmitted) / age;
if (avg >= 1.0) { if (avg >= 1.0) {
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has averaged %f cells transmitted " " * Cell-bearing channel " U64_FORMAT " has averaged %f "
"per second", "cells transmitted per second",
chan->global_identifier, avg); U64_PRINTF_ARG(chan->global_identifier), avg);
} else if (avg >= 0.0) { } else if (avg >= 0.0) {
interval = 1.0 / avg; interval = 1.0 / avg;
log(severity, LD_GENERAL, log(severity, LD_GENERAL,
" * Cell-bearing channel %lu has averaged %f seconds between " " * Cell-bearing channel " U64_FORMAT " has averaged %f "
"transmitted cells", "seconds between transmitted cells",
chan->global_identifier, interval); U64_PRINTF_ARG(chan->global_identifier), interval);
} }
} }
} }

View file

@ -118,8 +118,10 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
chan->u.cell_chan.write_var_cell = channel_tls_write_var_cell_method; chan->u.cell_chan.write_var_cell = channel_tls_write_var_cell_method;
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"In channel_tls_connect() for channel %p (global id %lu)", "In channel_tls_connect() for channel %p "
tlschan, chan->global_identifier); "(global id " U64_FORMAT ")",
tlschan,
U64_PRINTF_ARG(chan->global_identifier));
if (is_local_addr(addr)) channel_mark_local(chan); if (is_local_addr(addr)) channel_mark_local(chan);
channel_mark_outgoing(chan); channel_mark_outgoing(chan);
@ -137,8 +139,8 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
} }
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Got orconn %p for channel with global id %lu", "Got orconn %p for channel with global id " U64_FORMAT,
tlschan->conn, chan->global_identifier); tlschan->conn, U64_PRINTF_ARG(chan->global_identifier));
goto done; goto done;
@ -195,8 +197,8 @@ channel_tls_start_listener(void)
channel_tls_listener = listener; channel_tls_listener = listener;
log_debug(LD_CHANNEL, log_debug(LD_CHANNEL,
"Starting TLS listener channel %p with global id %lu", "Starting TLS listener channel %p with global id " U64_FORMAT,
lchan, lchan->global_identifier); lchan, U64_PRINTF_ARG(lchan->global_identifier));
channel_register(lchan); channel_register(lchan);
} else lchan = TLS_CHAN_TO_BASE(channel_tls_listener); } else lchan = TLS_CHAN_TO_BASE(channel_tls_listener);
@ -366,7 +368,9 @@ channel_tls_describe_transport_method(channel_t *chan)
id = TO_CONN(tlschan->conn)->global_identifier; id = TO_CONN(tlschan->conn)->global_identifier;
if (buf) tor_free(buf); if (buf) tor_free(buf);
tor_asprintf(&buf, "TLS channel (connection %lu)", id); tor_asprintf(&buf,
"TLS channel (connection " U64_FORMAT ")",
U64_PRINTF_ARG(id));
rv = buf; rv = buf;
} else { } else {

View file

@ -918,15 +918,17 @@ circuit_get_by_circid_channel_impl(circid_t circ_id, channel_t *chan)
if (found && found->circuit) { if (found && found->circuit) {
log_debug(LD_CIRC, log_debug(LD_CIRC,
"circuit_get_by_circid_channel_impl() returning circuit %p for" "circuit_get_by_circid_channel_impl() returning circuit %p for"
" circ_id %d, channel ID %lu (%p)", " circ_id %d, channel ID " U64_FORMAT " (%p)",
found->circuit, circ_id, chan->global_identifier, chan); found->circuit, circ_id,
U64_PRINTF_ARG(chan->global_identifier), chan);
return found->circuit; return found->circuit;
} }
log_debug(LD_CIRC, log_debug(LD_CIRC,
"circuit_get_by_circid_channel_impl() found nothing for" "circuit_get_by_circid_channel_impl() found nothing for"
" circ_id %d, channel ID %lu (%p)", " circ_id %d, channel ID " U64_FORMAT " (%p)",
circ_id, chan->global_identifier, chan); circ_id,
U64_PRINTF_ARG(chan->global_identifier), chan);
return NULL; return NULL;
/* The rest of this checks for bugs. Disabled by default. */ /* The rest of this checks for bugs. Disabled by default. */

View file

@ -193,8 +193,10 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
tor_assert(!(chan->is_listener)); tor_assert(!(chan->is_listener));
log_debug(LD_OR, log_debug(LD_OR,
"Got a CREATE cell for circ_id %d on channel %lu (%p)", "Got a CREATE cell for circ_id %d on channel " U64_FORMAT
cell->circ_id, chan->global_identifier, chan); " (%p)",
cell->circ_id,
U64_PRINTF_ARG(chan->global_identifier), chan);
if (we_are_hibernating()) { if (we_are_hibernating()) {
log_info(LD_OR, log_info(LD_OR,

View file

@ -157,8 +157,9 @@ connection_cpu_process_inbuf(connection_t *conn)
tag_unpack(buf, &chan_id, &circ_id); tag_unpack(buf, &chan_id, &circ_id);
circ = NULL; circ = NULL;
log_debug(LD_OR, log_debug(LD_OR,
"Unpacking cpuworker reply, chan_id is %lu, circ_id is %d", "Unpacking cpuworker reply, chan_id is " U64_FORMAT
chan_id, circ_id); ", circ_id is %d",
U64_PRINTF_ARG(chan_id), circ_id);
p_chan = channel_find_by_global_id(chan_id); p_chan = channel_find_by_global_id(chan_id);
if (p_chan) if (p_chan)