Commit 049f6c01 authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

Switch remaining files to new log interface.


svn:r5315
parent 7a9774ef
......@@ -87,6 +87,8 @@
/** Generic edge-connection functionality. */
#define LD_EDGE (1u<<16)
#define LD_EXIT LD_EDGE
/** Bandwidth accounting. */
#define LD_ACCT (1u<<17)
typedef void (*log_callback)(int severity, unsigned int domain, const char *msg);
......
......@@ -4,6 +4,7 @@
/* $Id$ */
const char dirserv_c_id[] = "$Id$";
#define NEW_LOG_INTERFACE
#include "or.h"
/**
......@@ -135,7 +136,7 @@ dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk)
{
char fp[FINGERPRINT_LEN+1];
if (crypto_pk_get_fingerprint(pk, fp, 0)<0) {
log_fn(LOG_ERR, "Error computing fingerprint");
err(LD_BUG, "Error computing fingerprint");
return -1;
}
if (!fingerprint_list)
......@@ -161,13 +162,13 @@ dirserv_parse_fingerprint_file(const char *fname)
cf = read_file_to_str(fname, 0);
if (!cf) {
log_fn(LOG_WARN, "Cannot open fingerprint file %s", fname);
warn(LD_FS, "Cannot open fingerprint file %s", fname);
return -1;
}
result = config_get_lines(cf, &front);
tor_free(cf);
if (result < 0) {
log_fn(LOG_WARN, "Error reading from fingerprint file");
warn(LD_CONFIG, "Error reading from fingerprint file");
return -1;
}
......@@ -176,31 +177,34 @@ dirserv_parse_fingerprint_file(const char *fname)
for (list=front; list; list=list->next) {
nickname = list->key; fingerprint = list->value;
if (strlen(nickname) > MAX_NICKNAME_LEN) {
log(LOG_NOTICE, "Nickname '%s' too long in fingerprint file. Skipping.", nickname);
notice(LD_CONFIG,
"Nickname '%s' too long in fingerprint file. Skipping.", nickname);
continue;
}
if (!is_legal_nickname(nickname) &&
strcasecmp(nickname, "!reject") &&
strcasecmp(nickname, "!invalid")) {
log(LOG_NOTICE, "Invalid nickname '%s' in fingerprint file. Skipping.", nickname);
notice(LD_CONFIG,
"Invalid nickname '%s' in fingerprint file. Skipping.", nickname);
continue;
}
if (strlen(fingerprint) != FINGERPRINT_LEN ||
!crypto_pk_check_fingerprint_syntax(fingerprint)) {
log_fn(LOG_NOTICE, "Invalid fingerprint (nickname '%s', fingerprint %s). Skipping.",
notice(LD_CONFIG,
"Invalid fingerprint (nickname '%s', fingerprint %s). Skipping.",
nickname, fingerprint);
continue;
}
if (0==strcasecmp(nickname, DEFAULT_CLIENT_NICKNAME)) {
/* If you approved an OR called "client", then clients who use
* the default nickname could all be rejected. That's no good. */
log(LOG_NOTICE,
notice(LD_CONFIG,
"Authorizing a nickname '%s' would break many clients; skipping.",
DEFAULT_CLIENT_NICKNAME);
continue;
}
if (add_fingerprint_to_dir(nickname, fingerprint, fingerprint_list_new) != 0)
log(LOG_NOTICE, "Duplicate nickname '%s'.", nickname);
notice(LD_CONFIG, "Duplicate nickname '%s'.", nickname);
}
config_free_lines(front);
......@@ -228,11 +232,11 @@ dirserv_router_get_status(const routerinfo_t *router, const char **msg)
fingerprint_list = smartlist_create();
if (crypto_pk_get_fingerprint(router->identity_pkey, fp, 0)) {
log_fn(LOG_WARN,"Error computing fingerprint");
warn(LD_BUG,"Error computing fingerprint");
return -1;
}
log_fn(LOG_DEBUG, "%d fingerprints known.", smartlist_len(fingerprint_list));
debug(LD_DIRSERV, "%d fingerprints known.", smartlist_len(fingerprint_list));
SMARTLIST_FOREACH(fingerprint_list, fingerprint_entry_t *, ent,
{
if (!strcasecmp(fp,ent->fingerprint))
......@@ -260,32 +264,32 @@ dirserv_router_get_status(const routerinfo_t *router, const char **msg)
router->addr, router->or_port, authdir_invalid_policy);
if (rej == ADDR_POLICY_PROBABLY_REJECTED || rej == ADDR_POLICY_REJECTED) {
log_fn(LOG_INFO, "Rejecting '%s' because of address %s",
router->nickname, router->address);
info(LD_DIRSERV, "Rejecting '%s' because of address %s",
router->nickname, router->address);
if (msg)
*msg = "Authdir is rejecting routers in this range.";
return FP_REJECT;
}
if (inv == ADDR_POLICY_PROBABLY_REJECTED || inv == ADDR_POLICY_REJECTED) {
log_fn(LOG_INFO, "Not marking '%s' valid because of address %s",
router->nickname, router->address);
info(LD_DIRSERV, "Not marking '%s' valid because of address %s",
router->nickname, router->address);
return FP_INVALID;
}
if (tor_version_as_new_as(router->platform,"0.1.0.2-rc"))
return FP_VALID;
else
return FP_INVALID;
log_fn(LOG_INFO,"No fingerprint found for '%s'",router->nickname);
info(LD_DIRSERV,"No fingerprint found for '%s'",router->nickname);
return 0;
}
if (0==strcasecmp(nn_ent->fingerprint, fp)) {
log_fn(LOG_DEBUG,"Good fingerprint for '%s'",router->nickname);
debug(LD_DIRSERV,"Good fingerprint for '%s'",router->nickname);
return FP_NAMED; /* Right fingerprint. */
} else {
log_fn(LOG_WARN,"Mismatched fingerprint for '%s': expected '%s' got '%s'. ContactInfo '%s', platform '%s'.)",
router->nickname, nn_ent->fingerprint, fp,
router->contact_info ? router->contact_info : "",
router->platform ? router->platform : "");
warn(LD_DIRSERV,"Mismatched fingerprint for '%s': expected '%s' got '%s'. ContactInfo '%s', platform '%s'.)",
router->nickname, nn_ent->fingerprint, fp,
router->contact_info ? router->contact_info : "",
router->platform ? router->platform : "");
if (msg)
*msg = "Rejected: There is already a verified server with this nickname and a different fingerprint.";
return FP_REJECT; /* Wrong fingerprint. */
......@@ -342,13 +346,14 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
if (get_options()->DirAllowPrivateAddresses)
return 0; /* whatever it is, we're fine with it */
if (!tor_inet_aton(ri->address, &iaddr)) {
log_fn(LOG_INFO,"Router '%s' published non-IP address '%s'. Refusing.",
ri->nickname, ri->address);
info(LD_DIRSERV,"Router '%s' published non-IP address '%s'. Refusing.",
ri->nickname, ri->address);
return -1;
}
if (is_internal_IP(ntohl(iaddr.s_addr))) {
log_fn(LOG_INFO,"Router '%s' published internal IP address '%s'. Refusing.",
ri->nickname, ri->address);
info(LD_DIRSERV,
"Router '%s' published internal IP address '%s'. Refusing.",
ri->nickname, ri->address);
return -1; /* it's a private IP, we should reject it */
}
return 0;
......@@ -373,7 +378,7 @@ authdir_wants_to_reject_router(routerinfo_t *ri,
/* Is there too much clock skew? */
now = time(NULL);
if (ri->published_on > now+ROUTER_ALLOW_SKEW) {
log_fn(LOG_NOTICE, "Publication time for nickname '%s' is too far (%d minutes) in the future; possible clock skew. Not adding (ContactInfo '%s', platform '%s').",
notice(LD_DIRSERV, "Publication time for nickname '%s' is too far (%d minutes) in the future; possible clock skew. Not adding (ContactInfo '%s', platform '%s').",
ri->nickname, (int)((ri->published_on-now)/60),
ri->contact_info ? ri->contact_info : "",
ri->platform ? ri->platform : "");
......@@ -381,7 +386,7 @@ authdir_wants_to_reject_router(routerinfo_t *ri,
return -1;
}
if (ri->published_on < now-ROUTER_MAX_AGE) {
log_fn(LOG_NOTICE, "Publication time for router with nickname '%s' is too far (%d minutes) in the past. Not adding (ContactInfo '%s', platform '%s').",
notice(LD_DIRSERV, "Publication time for router with nickname '%s' is too far (%d minutes) in the past. Not adding (ContactInfo '%s', platform '%s').",
ri->nickname, (int)((now-ri->published_on)/60),
ri->contact_info ? ri->contact_info : "",
ri->platform ? ri->platform : "");
......@@ -389,7 +394,7 @@ authdir_wants_to_reject_router(routerinfo_t *ri,
return -1;
}
if (dirserv_router_has_valid_address(ri) < 0) {
log_fn(LOG_NOTICE, "Router with nickname '%s' has invalid address '%s'. Not adding (ContactInfo '%s', platform '%s').",
notice(LD_DIRSERV, "Router with nickname '%s' has invalid address '%s'. Not adding (ContactInfo '%s', platform '%s').",
ri->nickname, ri->address,
ri->contact_info ? ri->contact_info : "",
ri->platform ? ri->platform : "");
......@@ -436,7 +441,7 @@ dirserv_add_descriptor(const char *desc, const char **msg)
/* Check: is the descriptor syntactically valid? */
ri = router_parse_entry_from_string(desc, NULL);
if (!ri) {
log(LOG_WARN, "Couldn't parse descriptor");
warn(LD_DIRSERV, "Couldn't parse uploaded server descriptor");
*msg = "Rejected: Couldn't parse server descriptor.";
return -2;
}
......@@ -447,9 +452,9 @@ dirserv_add_descriptor(const char *desc, const char **msg)
ri_old = router_get_by_digest(ri->identity_digest);
if (ri_old && ri_old->published_on < ri->published_on &&
router_differences_are_cosmetic(ri_old, ri)) {
log_fn(LOG_INFO,
"Not replacing descriptor from '%s'; differences are cosmetic.",
ri->nickname);
info(LD_DIRSERV,
"Not replacing descriptor from '%s'; differences are cosmetic.",
ri->nickname);
*msg = "Not replacing router descriptor; no information has changed since the last one with this identity.";
return 0;
}
......@@ -485,7 +490,7 @@ directory_remove_invalid(void)
router_status_t r = dirserv_router_get_status(ent, &msg);
switch (r) {
case FP_REJECT:
log(LOG_INFO, "Router '%s' is now rejected: %s",
info(LD_DIRSERV, "Router '%s' is now rejected: %s",
ent->nickname, msg?msg:"");
routerlist_remove(rl, ent, i--);
routerinfo_free(ent);
......@@ -493,14 +498,15 @@ directory_remove_invalid(void)
break;
case FP_NAMED:
if (!ent->is_verified || !ent->is_named) {
log(LOG_INFO, "Router '%s' is now verified and named.", ent->nickname);
info(LD_DIRSERV,
"Router '%s' is now verified and named.", ent->nickname);
ent->is_verified = ent->is_named = 1;
changed = 1;
}
break;
case FP_VALID:
if (!ent->is_verified || ent->is_named) {
log(LOG_INFO, "Router '%s' is now verified.", ent->nickname);
info(LD_DIRSERV, "Router '%s' is now verified.", ent->nickname);
ent->is_verified = 1;
ent->is_named = 0;
changed = 1;
......@@ -508,7 +514,8 @@ directory_remove_invalid(void)
break;
case FP_INVALID:
if (ent->is_verified || ent->is_named) {
log(LOG_INFO, "Router '%s' is no longer verified.", ent->nickname);
info(LD_DIRSERV,
"Router '%s' is no longer verified.", ent->nickname);
ent->is_verified = ent->is_named = 0;
changed = 1;
}
......@@ -745,7 +752,7 @@ dirserv_dump_directory_to_string(char **dir_out,
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
&identity_pkey_len)<0) {
log_fn(LOG_WARN,"write identity_pkey to string failed!");
warn(LD_BUG,"write identity_pkey to string failed!");
return -1;
}
......@@ -800,7 +807,7 @@ dirserv_dump_directory_to_string(char **dir_out,
goto truncated;
if (router_get_dir_hash(buf,digest)) {
log_fn(LOG_WARN,"couldn't compute digest");
warn(LD_BUG,"couldn't compute digest");
tor_free(buf);
return -1;
}
......@@ -812,7 +819,7 @@ dirserv_dump_directory_to_string(char **dir_out,
*dir_out = buf;
return 0;
truncated:
log_fn(LOG_WARN,"tried to exceed string length.");
warn(LD_BUG,"tried to exceed string length.");
tor_free(buf);
return -1;
}
......@@ -840,21 +847,21 @@ set_cached_dir(cached_dir_t *d, char *directory, time_t when)
{
time_t now = time(NULL);
if (when<=d->published) {
log_fn(LOG_INFO, "Ignoring old directory; not caching.");
info(LD_DIRSERV, "Ignoring old directory; not caching.");
tor_free(directory);
} else if (when>=now+ROUTER_MAX_AGE) {
log_fn(LOG_INFO, "Ignoring future directory; not caching.");
info(LD_DIRSERV, "Ignoring future directory; not caching.");
tor_free(directory);
} else {
/* if (when>d->published && when<now+ROUTER_MAX_AGE) */
log_fn(LOG_DEBUG, "Caching directory.");
debug(LD_DIRSERV, "Caching directory.");
tor_free(d->dir);
d->dir = directory;
d->dir_len = strlen(directory);
tor_free(d->dir_z);
if (tor_gzip_compress(&(d->dir_z), &(d->dir_z_len), d->dir, d->dir_len,
ZLIB_METHOD)) {
log_fn(LOG_WARN,"Error compressing cached directory");
warn(LD_BUG,"Error compressing cached directory");
}
d->published = when;
}
......@@ -943,11 +950,11 @@ dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
if (regenerate != NULL) {
if (dirty && dirty + DIR_REGEN_SLACK_TIME < time(NULL)) {
if (regenerate()) {
log_fn(LOG_ERR, "Couldn't generate %s?", name);
err(LD_BUG, "Couldn't generate %s?", name);
exit(1);
}
} else {
log_fn(LOG_INFO, "The %s is still clean; reusing.", name);
info(LD_DIRSERV, "The %s is still clean; reusing.", name);
}
}
return auth_src ? auth_src : cache_src;
......@@ -1011,13 +1018,13 @@ dirserv_regenerate_directory(void)
if (dirserv_dump_directory_to_string(&new_directory,
get_identity_key())) {
log(LOG_WARN, "Error creating directory.");
warn(LD_BUG, "Error creating directory.");
tor_free(new_directory);
return -1;
}
set_cached_dir(&the_directory, new_directory, time(NULL));
log_fn(LOG_INFO,"New directory (size %d) has been built.",(int)the_directory.dir_len);
log_fn(LOG_DEBUG,"New directory (size %d):\n%s",(int)the_directory.dir_len,
info(LD_DIRSERV,"New directory (size %d) has been built.",(int)the_directory.dir_len);
debug(LD_DIRSERV,"New directory (size %d):\n%s",(int)the_directory.dir_len,
the_directory.dir);
the_directory_is_dirty = 0;
......@@ -1051,7 +1058,7 @@ generate_runningrouters(void)
}
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
&identity_pkey_len)<0) {
log_fn(LOG_WARN,"write identity_pkey to string failed!");
warn(LD_BUG,"write identity_pkey to string failed!");
goto err;
}
format_iso_time(published, time(NULL));
......@@ -1068,7 +1075,7 @@ generate_runningrouters(void)
tor_free(router_status);
tor_free(identity_pkey);
if (router_get_runningrouters_hash(s,digest)) {
log_fn(LOG_WARN,"couldn't compute digest");
warn(LD_BUG,"couldn't compute digest");
goto err;
}
if (router_append_dirobj_signature(s, len, digest, private_key)<0)
......@@ -1162,7 +1169,7 @@ generate_v2_networkstatus(void)
const char *contact;
if (resolve_my_address(options, &addr, &hostname)<0) {
log_fn(LOG_WARN, "Couldn't resolve my hostname");
warn(LD_NET, "Couldn't resolve my hostname");
goto done;
}
in.s_addr = htonl(addr);
......@@ -1175,12 +1182,12 @@ generate_v2_networkstatus(void)
if (crypto_pk_write_public_key_to_string(private_key, &identity_pkey,
&identity_pkey_len)<0) {
log_fn(LOG_WARN,"Writing public key to string failed.");
warn(LD_BUG,"Writing public key to string failed.");
goto done;
}
if (crypto_pk_get_fingerprint(private_key, fingerprint, 0)<0) {
log_fn(LOG_ERR, "Error computing fingerprint");
err(LD_BUG, "Error computing fingerprint");
goto done;
}
......@@ -1254,25 +1261,25 @@ generate_v2_networkstatus(void)
f_stable?" Stable":"",
f_running?" Running":"",
f_valid?" Valid":"")<0) {
log_fn(LOG_WARN, "Unable to print router status.");
warn(LD_BUG, "Unable to print router status.");
goto done;
}
}
outp += strlen(outp);
});
if (tor_snprintf(outp, endp-outp, "directory-signature %s\n",
get_options()->Nickname)<0) {
log_fn(LOG_WARN, "Unable to write signature line.");
warn(LD_BUG, "Unable to write signature line.");
goto done;
}
if (router_get_networkstatus_v2_hash(status, digest)<0) {
log_fn(LOG_WARN, "Unable to hash network status");
warn(LD_BUG, "Unable to hash network status");
goto done;
}
if (router_append_dirobj_signature(outp,endp-outp,digest,private_key)<0) {
log_fn(LOG_WARN, "Unable to sign router status.");
warn(LD_BUG, "Unable to sign router status.");
goto done;
}
......@@ -1320,7 +1327,7 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
if (d)
smartlist_add(result, d);
else
log_fn(LOG_WARN,"Unable to generate an authoritative network status.");
warn(LD_BUG,"Unable to generate an authoritative network status.");
}
} else if (!strcmp(key, "all")) {
digestmap_iter_t *iter = digestmap_iter_init(cached_v2_networkstatus);
......@@ -1332,7 +1339,8 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
iter = digestmap_iter_next(cached_v2_networkstatus, iter);
}
if (smartlist_len(result) == 0)
log_fn(LOG_WARN, "Client requested 'all' network status objects; we have none.");
warn(LD_DIRSERV,
"Client requested 'all' network status objects; we have none.");
} else if (!strcmpstart(key, "fp/")) {
smartlist_t *digests = smartlist_create();
dir_split_resource_into_fingerprints(key+3, digests, NULL, 1);
......@@ -1351,7 +1359,7 @@ dirserv_get_networkstatus_v2(smartlist_t *result,
} else {
char hexbuf[HEX_DIGEST_LEN+1];
base16_encode(hexbuf, sizeof(hexbuf), cp, DIGEST_LEN);
log_fn(LOG_INFO, "Don't know about any network status with fingerprint '%s'", hexbuf);
info(LD_DIRSERV, "Don't know about any network status with fingerprint '%s'", hexbuf);
}
tor_free(cp);
});
......@@ -1460,11 +1468,11 @@ dirserv_orconn_tls_done(const char *address,
if (!ri->is_verified) {
/* We have a router at the same address! */
if (strcasecmp(ri->nickname, nickname_rcvd)) {
log_fn(LOG_NOTICE, "Dropping descriptor: nickname '%s' does not match nickname '%s' in cert from %s:%d",
notice(LD_DIRSERV, "Dropping descriptor: nickname '%s' does not match nickname '%s' in cert from %s:%d",
ri->nickname, nickname_rcvd, address, or_port);
drop = 1;
} else if (memcmp(ri->identity_digest, digest_rcvd, DIGEST_LEN)) {
log_fn(LOG_NOTICE, "Dropping descriptor: identity key does not match key in cert from %s:%d",
notice(LD_DIRSERV, "Dropping descriptor: identity key does not match key in cert from %s:%d",
address, or_port);
drop = 1;
}
......@@ -1474,7 +1482,7 @@ dirserv_orconn_tls_done(const char *address,
routerinfo_free(ri);
directory_set_dirty();
} else { /* correct nickname and digest. mark this router reachable! */
log_fn(LOG_INFO,"Found router %s to be reachable. Yay.", ri->nickname);
info(LD_DIRSERV,"Found router %s to be reachable. Yay.", ri->nickname);
ri->last_reachable = time(NULL);
ri->num_unreachable_notifications = 0;
}
......
......@@ -17,6 +17,7 @@ const char dns_c_id[] = "$Id$";
* them becomes more commonly available.
*/
#define NEW_LOG_INTERFACE
#include "or.h"
#include "tree.h"
......@@ -149,14 +150,14 @@ purge_expired_resolves(uint32_t now)
*/
while (oldest_cached_resolve && (oldest_cached_resolve->expire < now)) {
resolve = oldest_cached_resolve;
log(LOG_DEBUG,"Forgetting old cached resolve (address %s, expires %lu)",
debug(LD_EXIT,"Forgetting old cached resolve (address %s, expires %lu)",
safe_str(resolve->address), (unsigned long)resolve->expire);
if (resolve->state == CACHE_STATE_PENDING) {
log_fn(LOG_WARN,"Bug: Expiring a dns resolve ('%s') that's still pending. Forgot to cull it?", safe_str(resolve->address));
debug(LD_EXIT,"Bug: Expiring a dns resolve ('%s') that's still pending. Forgot to cull it?", safe_str(resolve->address));
tor_fragile_assert();
}
if (resolve->pending_connections) {
log_fn(LOG_WARN, "Closing pending connections on expiring DNS resolve!");
debug(LD_EXIT, "Closing pending connections on expiring DNS resolve!");
tor_fragile_assert();
while (resolve->pending_connections) {
pend = resolve->pending_connections;
......@@ -283,19 +284,19 @@ dns_resolve(connection_t *exitconn)
pending_connection->conn = exitconn;
pending_connection->next = resolve->pending_connections;
resolve->pending_connections = pending_connection;
log_fn(LOG_DEBUG,"Connection (fd %d) waiting for pending DNS resolve of '%s'",
debug(LD_EXIT,"Connection (fd %d) waiting for pending DNS resolve of '%s'",
exitconn->s, safe_str(exitconn->address));
exitconn->state = EXIT_CONN_STATE_RESOLVING;
return 0;
case CACHE_STATE_VALID:
exitconn->addr = resolve->addr;
log_fn(LOG_DEBUG,"Connection (fd %d) found cached answer for '%s'",
debug(LD_EXIT,"Connection (fd %d) found cached answer for '%s'",
exitconn->s, safe_str(exitconn->address));
if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
send_resolved_cell(exitconn, RESOLVED_TYPE_IPV4);
return 1;
case CACHE_STATE_FAILED:
log_fn(LOG_DEBUG,"Connection (fd %d) found cached error for '%s'",
debug(LD_EXIT,"Connection (fd %d) found cached error for '%s'",
exitconn->s, safe_str(exitconn->address));
if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR);
......@@ -344,14 +345,15 @@ assign_to_dnsworker(connection_t *exitconn)
dnsconn = connection_get_by_type_state(CONN_TYPE_DNSWORKER, DNSWORKER_STATE_IDLE);
if (!dnsconn) {
log_fn(LOG_WARN,"no idle dns workers. Failing.");
warn(LD_EXIT,"no idle dns workers. Failing.");
if (exitconn->purpose == EXIT_PURPOSE_RESOLVE)
send_resolved_cell(exitconn, RESOLVED_TYPE_ERROR_TRANSIENT);
goto err;
}
log_fn(LOG_DEBUG, "Connection (fd %d) needs to resolve '%s'; assigning to DNSWorker (fd %d)",
exitconn->s, safe_str(exitconn->address), dnsconn->s);
debug(LD_EXIT,
"Connection (fd %d) needs to resolve '%s'; assigning to DNSWorker (fd %d)",
exitconn->s, safe_str(exitconn->address), dnsconn->s);
tor_free(dnsconn->address);
dnsconn->address = tor_strdup(exitconn->address);
......@@ -384,7 +386,8 @@ connection_dns_remove(connection_t *conn)
resolve = SPLAY_FIND(cache_tree, &cache_root, &search);
if (!resolve) {
log_fn(LOG_NOTICE,"Address '%s' is not pending. Dropping.", safe_str(conn->address));
/* XXXX RD This *is* a bug, right? -NM */
notice(LD_BUG,"Address '%s' is not pending. Dropping.", safe_str(conn->address));
return;
}
......@@ -396,7 +399,7 @@ connection_dns_remove(connection_t *conn)
if (pend->conn == conn) {
resolve->pending_connections = pend->next;
tor_free(pend);
log_fn(LOG_DEBUG, "First connection (fd %d) no longer waiting for resolve of '%s'",
debug(LD_EXIT, "First connection (fd %d) no longer waiting for resolve of '%s'",
conn->s, safe_str(conn->address));
return;
} else {
......@@ -405,7 +408,7 @@ connection_dns_remove(connection_t *conn)
victim = pend->next;
pend->next = victim->next;
tor_free(victim);
log_fn(LOG_DEBUG, "Connection (fd %d) no longer waiting for resolve of '%s'",
debug(LD_EXIT, "Connection (fd %d) no longer waiting for resolve of '%s'",
conn->s, safe_str(conn->address));
return; /* more are pending */
}
......@@ -467,13 +470,14 @@ dns_cancel_pending_resolve(char *address)
resolve = SPLAY_FIND(cache_tree, &cache_root, &search);
if (!resolve) {
log_fn(LOG_NOTICE,"Address '%s' is not pending. Dropping.", safe_str(address));
/* XXXX RD This *is* a bug, right? -NM */
notice(LD_BUG,"Address '%s' is not pending. Dropping.", safe_str(address));
return;
}
if (!resolve->pending_connections) {
/* XXX this should never trigger, but sometimes it does */
log_fn(LOG_WARN,"Bug: Address '%s' is pending but has no pending connections!",
warn(LD_BUG,"Bug: Address '%s' is pending but has no pending connections!",
safe_str(address));
tor_fragile_assert();
return;
......@@ -481,8 +485,8 @@ dns_cancel_pending_resolve(char *address)
tor_assert(resolve->pending_connections);
/* mark all pending connections to fail */
log_fn(LOG_DEBUG, "Failing all connections waiting on DNS resolve of '%s'",
safe_str(address));
debug(LD_EXIT, "Failing all connections waiting on DNS resolve of '%s'",
safe_str(address));
while (resolve->pending_connections) {
pend = resolve->pending_connections;
pend->conn->state = EXIT_CONN_STATE_RESOLVEFAILED;
......@@ -551,8 +555,8 @@ dns_found_answer(char *address, uint32_t addr, char outcome)
resolve = SPLAY_FIND(cache_tree, &cache_root, &search);
if (!resolve) {
log_fn(LOG_INFO,"Resolved unasked address '%s'; caching anyway.",
safe_str(address));
info(LD_EXIT,"Resolved unasked address '%s'; caching anyway.",
safe_str(address));
resolve = tor_malloc_zero(sizeof(cached_resolve_t));
resolve->state = (outcome == DNS_RESOLVE_SUCCEEDED) ?
CACHE_STATE_VALID : CACHE_STATE_FAILED;
......@@ -565,7 +569,7 @@ dns_found_answer(char *address, uint32_t addr, char outcome)
if (resolve->state != CACHE_STATE_PENDING) {
/* XXXX Maybe update addr? or check addr for consistency? Or let
* VALID replace FAILED? */
log_fn(LOG_NOTICE, "Resolved '%s' which was already resolved; ignoring",
notice(LD_EXIT, "Resolved '%s' which was already resolved; ignoring",
safe_str(address));
tor_assert(resolve->pending_connections == NULL);
return;
......@@ -656,7 +660,7 @@ connection_dns_finished_flushing(connection_t *conn)
int
connection_dns_reached_eof(connection_t *conn)
{
log_fn(LOG_WARN,"Read eof. Worker died unexpectedly.");
warn(LD_EXIT,"Read eof. Worker died unexpectedly.");
if (conn->state == DNSWORKER_STATE_BUSY) {
/* don't cancel the resolve here -- it would be cancelled in
* connection_about_to_close_connection(), since conn is still
......@@ -682,8 +686,8 @@ connection_dns_process_inbuf(connection_t *conn)
tor_assert(conn->type == CONN_TYPE_DNSWORKER);
if (conn->state != DNSWORKER_STATE_BUSY && buf_datalen(conn->inbuf)) {
log_fn(LOG_WARN,"Bug: read data (%d bytes) from an idle dns worker (fd %d, address '%s'). Please report.",
(int)buf_datalen(conn->inbuf), conn->s, safe_str(conn->address));
warn(LD_BUG,"Bug: read data (%d bytes) from an idle dns worker (fd %d, address '%s'). Please report.",
(int)buf_datalen(conn->inbuf), conn->s, safe_str(conn->address));
tor_fragile_assert();
/* Pull it off the buffer anyway, or it will just stay there.
......@@ -692,7 +696,7 @@ connection_dns_process_inbuf(connection_t *conn)
while (buf_datalen(conn->inbuf)) {
connection_fetch_from_buf(&success,1,conn);
connection_fetch_from_buf((char *)&addr,sizeof(uint32_t),conn);
log_fn(LOG_WARN,"Discarding idle dns answer (success %d, addr %d.)",
warn(LD_EXIT,"Discarding idle dns answer (success %d, addr %d.)",
success, addr); // XXX safe_str
}
return 0;
......@@ -705,8 +709,8 @@ connection_dns_process_inbuf(connection_t *conn)
connection_fetch_from_buf(&success,1,conn);
connection_fetch_from_buf((char *)&addr,sizeof(uint32_t),conn);
log_fn(LOG_DEBUG, "DNSWorker (fd %d) returned answer for '%s'",
conn->s, safe_str(conn->address));
debug(LD_EXIT, "DNSWorker (fd %d) returned answer for '%s'",
conn->s, safe_str(conn->address));
tor_assert(success >= DNS_RESOLVE_FAILED_TRANSIENT);
tor_assert(success <= DNS_RESOLVE_SUCCEEDED);
......@@ -784,17 +788,17 @@ dnsworker_main(void *data)
if ((r = recv(fd, &address_len, 1, 0)) != 1) {
if (r == 0) {
log_fn(LOG_INFO,"DNS worker exiting because Tor process closed connection (either pruned idle dnsworker or died).");
info(LD_EXIT,"DNS worker exiting because Tor process closed connection (either pruned idle dnsworker or died).");
</